Rediscovering Excel Macros
What is a macro? Macros are Visual Basic for Applications (VBA) codes that are saved inside a document. They can be applied in several Microsoft Office Applications. An analogy is to think of a document as HTML and the macro as Javascript. A macro can manipulate a document similarly to the way Javascript can manipulate a web page. Macros are powerful and can do many things including; apply style and formatting, manipulate data and text, communicate with data sources, create entirely new documents, and any combination of these.
You must be asking, how can a macro help me? They allow you to save time on predictable, repetitive tasks as well as standardizing document formats. Now without having to write a single line of code! I found myself having to run the same data sets for different libraries in our system regularly and exporting them into Excel spreadsheets. I grew tired of all the customization and formatting within Excel I had to do each time. Excel Macros were the answer for me! Not only have they saved me time, but they have also helped improve consistency and accuracy.
To create an Excel macro simply import your spreadsheet into Microsoft Excel.
- Select the View tab
- From there, select the Macros button and highlight the down arrow and select Record Macro.
- From this point, go ahead and make your desired changes to the spreadsheet as you would normally do.
- When you are finished with your changes, go back to the Macro button down arrow and you will now select the option to Stop Recording.
- Close out of Excel and save your Macro.
- Once completed, the macro will be available anytime you open Excel under the Macro menu.
- Simply select View Macro and select which macro to use (if you have more than one saved).
- Then hit the Run button.
- The macro I created for the Library Weeding Reports completes the following tasks in Excel with just one click;
- Bolds and freezes the top row
- Converts barcodes to a number without decimal places
- Changes the print orientation to landscape
- Sets the correct margins
- Wraps the text
(See my spreadsheet changes below.)
I have gone on to create many Excel macros for the different data sets I run. It’s amazing how intuitive macros have become in the last several versions of Microsoft Excel. Please share with us how you use macros in the comments.