An Excel macro is a recording of steps that you've taken in Excel. Those steps can then be played back on demand to repeat the process exactly as recorded.
- [Instructor] A macro is simply a VBA procedure. VBA is short for Visual Basic for Applications, which is a subset of programming languages Microsoft uses to build Office. You can use the macro recorder to create macros, and you can also write your own VBA code. The big difference between the two is that recorded macros are non-deterministic, meaning they can't make decisions on their own. A recorded macro will do the same thing whether it's the first time you run it, or the hundredth. On the other hand, macros can take on a life of their own when you actually get into the VBA environment and start asking your code to make decisions for you.
For example, here's a quick macro I wrote that populates a worksheet with a bunch of random numbers, applies some conditional formatting, then repeats itself as many times as you want. I'm going to tell it to repeat 10 times. Now that's all in good fun, but for more real world applications, you might want Excel to prompt you to where to save a file, or who to send an email to. You can also respond to events, like asking someone if they want to spell check before they print a workbook, or add a date/time stamp to a cell when another cell's changed. If you can think of automating some part of your work in Excel, then the odds are that you can.
For this course, we'll be working on a common scenario with a 12-month cash flow report that has multiple worksheets. So for example, here, I've got a 12-month cash flow, 12-month summary, 12 months of expense data, sales detail, chart of accounts, consolidated data, and so on. I don't need everybody to see the rest of those worksheets. I just need them to see the two primary report sheets. That's not a big deal. I can just go hide those sheets before I send this out every time. The big pain point comes when I actually want to work on this workbook again, I have to unhide those worksheets, and then I've got to rehide them when I want to send the workbook out again.
With a macro, I can do all that at the press of a button like this. Hide sheets, all my sheets are hidden. Press the button again, they're all unhidden. And I'll show you how to do this. I'll also walk you through how to get started with VBA. Note that this will just be a primer, as there are exhaustive courses on VBA programming if you want to pursue it.