Alright, so I’ll get laughed at here, but one of my ‘goals’ for work this year is I wanted to take the 4 hour VBA course on youtube and then write a small program after it that does something.

Before you laugh at me using an outdated language, I only chose it because a co worker suggested learning it, and we do use some VBA coded macros in our spreadsheets. We’re not a very up to date company.

The reason I never get anything done with learning programming is I never know what to do . And if I do come up with something to do, it will be WAYY too complex over my head, i’ll fail at it, then never touch it again. If it’s too simple, I won’t even want to bother. (Yay ADHD)

So I’m just looking for a couple suggestions for a fun little program to make (and consider the goal ‘done’). I know calculators of some sort are an option…I can’t really think of anything else. I guess it doesn’t actually have to be a useful program but it would be cool if it was.

  • Buddahriffic@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    1 day ago

    Try making a game. I think minesweeper might be a good one because it can be broken down into many different problems with different complexities. Like user input could start out as entering coordinates into specific cells to interact with a seperate grid, then you could switch to using an input grid where you enter a value into the cell you want, and then move on to clicking on cells like in the real minesweeper, including different behaviours for left, right, and both clicks.

    Pretty sure you could implement a full version of minesweeper in excel, though even if you can’t get all the way, there should be enough low hanging fruit you can reach to learn a lot from the process.

    Or if you’re feeling really ambitious, I think a realistic physics racing simulator is also possible, though I wouldn’t expect a lot on the graphics side of such a thing. Just lots of formulas that then get used to simulate a car accelerating, braking, and turning. But this one might also be great to get started with because you can start with a simple model and add complexity from there.

  • antlion@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    2
    ·
    1 day ago

    Functions are somewhat useful in VBA although learning LAMBDA in cell formulas (and named ranges) would probably serve you better at this time.

    So instead I would say focus on writing a Sub. The one I used for myself students was to turn the current selection into a checkerboard by resizing column width to 2 and coloring every other square black (or any color).

  • At work, if you already have an existing workflow or process that’s repetitive and you have some level of familiarity with, start with that. You will already be clear about the outcomes you want.

    VBA is nice in that since you are manipulating an Office product (usually Excel), you get to see what your code actually does in “real-time”. Running the code line by line (Debug mode IIRC) helps.

    Don’t worry about it being “old”, it’s still useful in most corporate settings and like others have said, much of the concepts are transferrable. Myself I went on from VBA to other Microsoft products like Power Query and DAX.

    One word of advice, always work on copies! Treat VBA processes as destructive and non-reversible!!! Last thing you want is to mangle “live” files beyond repair…

    Have fun :)

  • ApocolypticGopher@infosec.pub
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 day ago

    Personally I always get excited by process automaton. Been a minute since I’ve done any VBA but my favorite projects I used it for were probably:

    1. Bulk updating CAD models and drawings as part of rebranding. (Solidworks)
    2. Interacting with a 5250 emulator (AS400) to automate the data entry/extraction I was doing
  • Consti@lemmy.world
    link
    fedilink
    arrow-up
    8
    arrow-down
    1
    ·
    2 days ago

    VBA can be used in place of scripts on Windows through the use of wscript.exe, so you might want to find any small thing you want to automate and figure out how to do that

  • mvirts@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    2 days ago

    The best part of vba is you can record a Macro then edit it. I think you should start by adding a button that shows a message box when you press it, then record a Macro and throw some message boxes in it to see what values are used. Beware, office 365 has some other thing besides vba that I’m not familiar with, you may be better off learning that.

  • e0qdk@reddthat.com
    link
    fedilink
    arrow-up
    4
    ·
    2 days ago

    I wrote some VBA for a job a long time ago. It was pretty good for making quick and dirty UI in Excel – like, click a cell and have it pop up a form you can interact with that will let you do data entry with less clicks/typing than whatever Excel would’ve made you do if you had to do it naively.

    I used it for showing a list that could be filtered down by partially typing in text in one project. (A really basic autocomplete sort of thing, essentially.) For another project, I integrated IE and showed some complex data in the embedded browser with buttons (or maybe it was checkboxes? been too many years) in the form to quickly classify it and move on to the next entry without having to flip back and forth between multiple programs and manually open files. (Each entry corresponded to a row and widgets on the form updated values in various columns so I could go through all the data and fill out the full spreadsheet super fast.)

    Alternatively, write a script that checks your spreadsheet for errors. e.g. add a reference to a regex library and use it verify that all the entries in a column match the data format you expect (like serial number patterns with hyphens in specific places).

    You can also ask your coworkers for something tedious they have to do a lot in Excel and see if you can find a way to make it less tedious.

  • petrichornetrainfall@piefed.social
    link
    fedilink
    English
    arrow-up
    4
    ·
    2 days ago

    Learning one language makes it easier to learn another, so dont worry about which one you start with. Basically the “language” or vocabulary changes, but the underlying “grammer” (as in noun, pronoun, subject, adjective, etc) is for the most part universal. Like knowing what a library, functuon, method, class, loop, variable, etc will be transferable.

    For a project, I dont know what you do for work, but you mentioned vba macros in spreadsheet, so id recommend building off of that. As someone else with adhd, the more interested I am in something, the more motivated I am in pushing through roadblocks when its not instantly easy. So id recommend trying to automate some task you do manually for work, something you know a lot about and know what the inputs and outputs should look like, and write something for that.

  • jubilationtcornpone@sh.itjust.works
    link
    fedilink
    arrow-up
    1
    ·
    2 days ago

    Create custom functions. Excel has lots of built in functions. “SUM()”, “CONCAT()”, etc. You can use VBA to create your own functions that manipulate data within cells.

  • tal@lemmy.today
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 days ago

    The traditional first program for a language is one that displays the text “hello, world”.

    https://en.wikipedia.org/wiki/Hello,_world

    A “Hello, world” program is usually a simple computer program that displays on the screen (often the console) a message similar to “Hello, World!”. A small piece of code in most general-purpose programming languages, this program is used to illustrate a language’s basic syntax. Such a program is often the first written by a student of a new programming language,[1] but it can also be used as a sanity check to ensure that the computer software intended to compile or run source code is correctly installed, and that its operator understands how to use it.

    https://riptutorial.com/excel-vba/example/13182/hello-world

    Now, you might want to do something more-elaborate too, but maybe make that the second program rather than the first.

  • perishthethought@piefed.social
    link
    fedilink
    English
    arrow-up
    2
    ·
    2 days ago

    Here’s an idea:

    • find a Excel workbook you / your team uses a lot.
    • use VBA to add a button onto the main sheet labeled something like, “Lock”.
    • when someone clicks it, that sheet gets locked from edits (“protected”) and the label on the button changes to, “Unlock”
    • When Unlock is clicked, the protections are removed

    A couple of notes:

    • practice this on a COPY of the sheet you all rely on
    • know that VBA has a ton of really odd things about its language – things that no other language (that I know of) does

    So learn as you go, build up your confidence, but keep in mind that not everything you learn will apply to other newer languages you might eventually learn.

    Have fun, be patient, ask for help whenever you get stuck!

  • lmr0x61@lemmy.ml
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    1
    ·
    2 days ago

    Hey man, someone’s gotta learn VBA! It’ll probably outlive both of us, if Microsoft keeps it around in any capacity.

  • Nolvamia@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 days ago

    I taught myself VBA when I inherited a job that involved taking data from multiple sources and producing summary reports of various types for multiple stakeholders. The person before me spent days each week doing it, it took me about a week of learning and playing to bring that down to 5 minutes or so.

    I found VBA useful for dealing with administrivia.

    I ended up doing similar things multiple times afterwards, with variations on source data (excel, text files, word docs), source data location (local drive, network, databases, SharePoint) and output (pivots, charts, tables, text files, email, word docs, etc.) depending on what was needed. Someone else mentioned data validation already.

    Automate the boring stuff.