Skip to content

Record your first macro

Record and run macros10 minPremium

Builds on What macros do, and how to open them safely.

An office manager at a group of dental practices in Columbus gets the week's appointments as an export every Friday. Before she sends it to the clinics, she bolds the headings, sets the dates to one format and fits the columns. Recorded once, the routine runs next Friday in a second.

How it works

The macro recorder writes down what you do, as VBA, until you tell it to stop.

  1. On the Developer tab, select Record Macro. On Windows, the small Record Macro button at the left of the status bar does the same.
  2. Fill in the Record Macro dialog and select OK.
  3. Do the steps once. The recorder writes down your actions and ignores the time between them, so work at your own pace.
  4. Select Stop Recording, in the same place.
RowAB
1BoxWhat goes in it
2Macro nameLetters, numbers and underscores, starting with a letter and with no spaces: FormatAppointments
3Shortcut keyA letter. A lowercase letter gives Ctrl and the letter; a capital gives CtrlShift and the letter
4Store macro inThis Workbook keeps the macro in the file you're working on. Personal Macro Workbook keeps it in a hidden workbook that opens every time Excel starts, so it works in any file on your computer. New Workbook puts it in a new file
5DescriptionWhat the macro does, for whoever finds it later

A macro's shortcut replaces Excel's own while the workbook is open, so a macro on CtrlC stops copying from working. Excel uses far fewer CtrlShift letters, so a capital is the safer choice.

Run it

Choose View > Macros, or Developer > Macros, or press AltF8. Select the macro and select Run. Its shortcut key runs it too.

Excel can't undo a macro: after it runs, CtrlZ has nothing to take back. Save first, or try a new macro on a copy of the workbook.

Common mistakes

  • A name with a space, such as Format appointments. Excel won't accept it; use FormatAppointments or Format_Appointments.
  • Forgetting to stop. Every click goes into the macro until you select Stop Recording.
  • Storing a team's macro in the Personal Macro Workbook. That workbook stays on your computer, so colleagues who open the file don't get the macro.

In short

  • Record Macro, do the steps once, then Stop Recording.
  • Run a macro from View > Macros, AltF8 or its shortcut, and give it a capital letter so it clashes with fewer of Excel's shortcuts.
  • Store it in This Workbook for a file's own job, or in the Personal Macro Workbook for a job you do in every file.

Practice

Premium

5 exercises: 1 set of steps, 1 dialog, 1 quiz question, 1 shortcut and 1 find-it task.

Practice is part of Premium

Every lesson is free to read, and you can practice the free lessons without an account. This lesson's exercises are part of Premium, which you add to a free account.