A coworker emailed me and asked about macros. So I decided to blog about it.
What is a macro?
A macro is a robot who can imitate what you do and do it for you the next time because you’ve told it what to do. I am sure there’s a fancier definition than that. But, that all a macro is.
How to record it
1. Check to see if you have the developer tab. Congratulations, by the way. Because you’re now recording macros, Microsoft considers you a developer. That’s pretty awesome. 🙂
2. If you don’t have the developer tab, go to the Office Button >Excel Options > Popular > check Show Developer in the Ribbon
3. Click on Developer > Record Macro
4. You should have something like this
First, a record macro dialog box comes up. It asks you to name your macro. Depending on your purpose, name your macro to reflect the intent of your macro so that the next time you use it, you remember it.
Once you do that, look at the bottom left corner, a blue square appears indicating a “recording session” is in progress. That means some of your movement in Excel is now being “watched” and recorded.
5. Do something in Excel. Color a block of cells yellow. Type “I’m awesome” in one of those cells.
6. Go back to the Developer tab if you’re not there already. Click on Stop Recording
7. Now, let’s manually delete your sentence “I’m awesome”. Let’s also make sure your highlighted cell(s) is not yellow. We’re basically testing our robot. We want to see if it can do what we had programmed it to do.
8. Once you’ve done # 7, go back to the Developer Tab, click on Macros, choose the Macro you just created and click on Run.
9. Your macro should do exactly what you told it to do.
I’m showing you something very simple but powerful here. Imagine having to do something repetitive like color format and format text each time you open a file. What takes us minutes and hours to do only takes a macro like this seconds and in some cases less than a second.
There are so much more to Macros. Of course, you can even use Visual Basic Application (VBA), an embedded programming language in Excel, to tweak your macros for more advance instructions. Imagine telling your robots to send an email to people at a specific time using predefined reports. But, the steps above, for now, should help you simplify your spreadsheet life.