4. Select Store macro in: This Workbook then click the OK button.
Excel is now recording your actions to create a macro.
5. Select Columns A & B and then right-click on the highlighted Column Bar to Hide them.
6. Then select Column I and press Ctrl + Shift + Right Arrow to include all remaining columns on the right.
7. Right-click on the highlighted Column Bar then click on Hide.
Your worksheet should now look like this:
To end the macro recording:
8. On the View ribbon, click on Macros and select Stop Recording.
Good job! 👏
You have created your first macro in Excel!
But wait, where is the recorded macro?
To view all of the available Excel macros :
1. Select View Macros.
2. This opens the Macro window. Saved macros will be listed here and you can Run whichever one you need.
You can also click on Edit to view the VBA code window.
3. The VBA code editor opens.
Notice the Hide_Columns Sub procedure. You don’t have to write or edit VBA code for the macro.
Excel automatically generated each code line based on the recorded keystrokes and mouse clicks.
The Record Macro feature is powerful enough for general spreadsheet automation needs.
But if you want to customize your own VBA macro, you can learn more about Visual Basic for Applications (VBA) here.
Using the Developer tab
Let’s record another macro to Unhide the hidden columns.
This time, you can record the macro from the Developer tab.
The Developer tab gives you access to a lot of useful Microsoft Excel features such as the Visual Basic Editor. It also allows you to quickly insert form controls such as buttons and checkboxes.
However, the Developer tab is not visible in the Excel ribbon by default.
To add it:
1. Right-click on the Excel ribbon.
Select Customize the Ribbon.
2. This opens the Customize Ribbon window.
On the right side, check the Developer tab checkbox.
3. You should now see the Developer tab.
To start recording the Unhide macro:
1. Click on the Record Macro button in the Developer tab.
2. Name this macro Unhide_Columns.
3. Click OK.
The recording has started.
4. Press Ctrl + A twice to select all cells.
5. Right-click anywhere on the Column Bar then click Unhide.
6. Click on the Stop Recording macro button to finish up.
Great work! 👌
Now you have two recorded macros that can be executed.