How to Use Macros in Excel: 15 Steps

Table of contents:

How to Use Macros in Excel: 15 Steps
How to Use Macros in Excel: 15 Steps
Anonim

In some cases, a worksheet contains an operation that must be repeated regularly. You can create a macro to easily repeat it without having to follow the steps again. Follow this guide to learn how to save time with Excel macros.

Steps

Method 1 of 2: Use Macros in Excel (except Excel 2008 for Mac)

Use Macros in Excel Step 1
Use Macros in Excel Step 1

Step 1. Verify that macros are enabled in the settings

This setting is found in the "Security" section in most versions of Excel.

Use Macros in Excel Step 2
Use Macros in Excel Step 2

Step 2. Open the workbook that contains or will contain macros

Use Macros in Excel Step 3
Use Macros in Excel Step 3

Step 3. Verify that macros are enabled in that workbook

Use Macros in Excel Step 4
Use Macros in Excel Step 4

Step 4. Consider how you want to use the macro

You can run macros from a menu, link them to a workbook button, set them to run automatically when you open a worksheet, or link them to a keyboard command.

Use Macros in Excel Step 5
Use Macros in Excel Step 5

Step 5. Record or write your macro, to repeat the particular operations you want to automate, if there is not already a macro in your folder that you can use

To record the macro, find the "Record New Macro" command. The your operating system and your personal Excel configuration

Use Macros in Excel Step 6
Use Macros in Excel Step 6

Step 6. Open the macro menu, which you will usually find in the "Tools" section of Excel

Use Macros in Excel Step 7
Use Macros in Excel Step 7

Step 7. Test the macro you want to use, making sure it works correctly

Use Macros in Excel Step 8
Use Macros in Excel Step 8

Step 8. Assign the macro to any button, keyboard key, or auto-run on the worksheet

Use Macros in Excel Step 9
Use Macros in Excel Step 9

Step 9. Run the macro

Method 2 of 2: Use Macros with Excel 2008 for Mac

Use Macros in Excel Step 10
Use Macros in Excel Step 10

Step 1. Open the workbook where you want to insert the macro

Use Macros in Excel Step 11
Use Macros in Excel Step 11

Step 2. Open "Script Utility", which you will find in the "AppleScript" folder, inside your global "Applications" folder

(The global "Applications" folder is what you can see before opening your account root folder.

Use Macros in Excel Step 12
Use Macros in Excel Step 12

Step 3. Press the "record" button and perform the operations you want to insert into the macro

Use Macros in Excel Step 13
Use Macros in Excel Step 13

Step 4. Verify that the macro you recorded works correctly (Not all actions are automatable, which means that you cannot record them in an AppleScript)

Use Macros in Excel Step 14
Use Macros in Excel Step 14

Step 5. Save the AppleScript you recorded

Use Macros in Excel Step 15
Use Macros in Excel Step 15

Step 6. Run the AppleScript

Advice

  • If you create your own macros, it will be easier to find errors if you log each operation individually. Check each section independently, and you will be able to edit any that contain errors. When everything works fine, turn the macro into a single program.
  • If the macro was created on a different computer than the one you will be using it on, some changes will be required to run it correctly. Visual Basic for Applications (VBA, the programming language for Excel macros) is slightly different between the Windows and Mac versions.
  • If you want to automatically enable macros, some versions of Excel allow you to save a macro-enabled workbook as an XLSM file and set preferences for particular folders where macros will always be accepted.

Warnings

  • Viruses can hide in Excel macros. If a workbook contains an unfamiliar macro, verify that it was intentionally added by someone you trust.
  • Macros can also damage Excel files, accidentally or intentionally. Be sure to back up your spreadsheet before activating a macro.

Recommended: