This wikiHow teaches you how to create a simple macro for an Excel spreadsheet.
Step
Part 1 of 3: Enabling Macros
Step 1. Run Excel
You can do the same process to enable macros in Excel 2010, 2013, and 2016. There are slight differences in Excel for Mac, which are explained below.
Step 2. Click the File tab
On a Mac, click the "Excel" menu
Step 3. Click Options
On a Mac, click the " Preferences " option
Step 4. Click the Customize Ribbon option
On a Mac, click " Ribbon & Toolbar " in the " Authoring " section
Step 5. Check the Developer box in the list on the right
On a Mac, you can find "Developer" in the "Tab or Group Title" list
Step 6. Click OK
The Developer tab will appear at the end of the tabs list.
Part 2 of 3: Recording Macros
Step 1. Practice the macro sequence
When recording a macro, anything clicked or done is recorded. So, one mistake can ruin everything. Do the practice of running the recording command a few times so you can do it without hesitation and without mis-clicking.
Step 2. Click the Developer tab
Step 3. Click Record Macro
This option is in the Code section of Excel's ribbon. You can also start a new macro by pressing Alt+T+M+R keys (Windows only).
Step 4. Name the macro
Use an easily recognizable name, especially if you want to create multiple macros.
You can also provide a description to explain the function of the macro
Step 5. Click the Shortcut key field
You can create a keyboard shortcut so that the macro can be run easily. However, this is optional.
Step 6. Press the Shift key and a letter
A keyboard combination of Ctrl+⇧ Shift+letter will be created to run the macro.
On Mac computers, the keyboard combination is Opt+⌘ Command+letter
Step 7. Click the Store macro in menu
Step 8. Click the location where you want to save the macro
If the macro is only used for the spreadsheet at this point, leave its location in " This Workbook ". If you want a macro to be used for all the spreadsheets you work with, select " Personal Macro Workbook ".
Step 9. Click OK
The macro will start recording.
Step 10. Perform the command you want to record
Anything you do at this point will be recorded and added to the macro. For example, if you run the sum formula A2 and B2 in cell C7, Excel will add up A2 and B2, and then display the result in C7 when you run the macro in the future.
Macros can be very complex, and you can even use them to run other Office programs. When a macro records, almost anything that was done in Excel is added to the macro
Step 11. Click Stop Recording when you are done
The recording of the macro will end and the result will be saved.
Step 12. Save the file in a format that has macro enabled
In order for macros to be preserved, you must save the workbook in an Excel format that has macros enabled:
- Select the File menu, then click Save.
- Click the File Type menu under the file name field.
- Click Excel Macro-Enabled Workbook.
Part 3 of 3: Using Macros
Step 1. Open the workbook file that has macros enabled
If you closed the file before running the macro, you will be prompted to activate the content.
Step 2. Click Enable Content
This option will appear at the top of the Excel spreadsheet on the Security Warning bar whenever a workbook that has macros enabled is opened. Since this is your own file, of course you can trust it. However, be careful when opening files that have other people's macros enabled.
Step 3. Hit your macro shortcut
If you want to use a macro, you can run it quickly by pressing the shortcut you have created.
Step 4. Click the Macros button in the Developer tab
All available macros in your spreadsheet at this point will be displayed.
Step 5. Click the macro you want to run
Step 6. Click the Run button
The macro will run in your cell or selection at this point.
Step 7. Look at the macro code
If you want to know how macro coding works in more detail, open the macro code you created and tinker with its contents:
- Click the Macros button located on the Developer tab.
- Click the macro you want to view.
- Click Edit.
- Look at the macro code in the Visual Basic code editing program.