Maintenance Notification: We are upgrading our servers today so you may experience intermediate outages. Thank you for your patience.
Create and modify simple macros
MO-211

Name simple macros

  1. 1View › Macros › Record Macro.
  2. 2Macro name: the exact name the task gives, such as FormatHeader.
  3. 3Store macro in: This Workbook.
  4. 4OK, record, then Stop Recording.

The name is set in the Record Macro dialog, before you record. It must be a single word Excel can use as a VBA name, and the task's spelling is the one the grader looks for.

What the MO-211 task asks

Every recording task in our MO-211 practice exams names the macro: FormatHeader, ClearFares, NightClose, RoundClose. Our grader's first check is that a macro of exactly that name exists in the workbook, so the name is worth as many points as the steps.

A macro name is a VBA name: letters, digits and underscores, starting with a letter, with no spaces. Type the task's name exactly, in the same case, and store the macro in This Workbook.

Worked examples

Set up the grid below to follow along. Each example starts from it as shown; every result is what Excel showed.

Log
ABCD
1DateVesselBerthFee
A valid name
Do this
  1. 1Name the macro Format_Header.
Excel showsIt records and runs

Underscores are allowed, so Format_Header is a usable name.

A space in the name
Do this
  1. 1Name the macro Format Header.
Excel showsNot a valid macro name

A space splits the name into two words. Use FormatHeader or Format_Header.

A name that starts with a digit
Do this
  1. 1Name the macro 2Header.
Excel showsNot a valid macro name

A macro name has to start with a letter.

In the video
Do this
  1. 1Record Macro.
  2. 2Macro name FormatHeader, Store macro in This Workbook.
  3. 3OK, Ctrl+B on A1:D1, Stop Recording, then Alt+F8.
Excel showsFormatHeader in View Macros

The name and the store choice, done in Excel.

Watch it done in Excel

The last example above, recorded in real Excel on the same grid.

Exam traps

A different spelling

Format_Header is a valid name, but it is not FormatHeader. The grader looks for the name the task gives.

Keeping Macro1

The dialog suggests Macro1. Selecting OK without changing it records a macro the task did not ask for.

Personal Macro Workbook

The name can be right and the macro still missing from the file, if Store macro in is set to Personal Macro Workbook.

FAQ

Can I rename a macro after recording it?

Yes, in the Visual Basic Editor: change the name after Sub on the macro's first line.

Does case matter?

Excel treats formatheader and FormatHeader as the same macro, but type the task's name as given.

What is the shortcut key box for?

It assigns Ctrl+ a letter to run the macro. The tasks do not ask for one, so leave it empty.

Try it under exam conditions

Take a full, timed MO-211 practice exam, upload the workbook you built, and get a score out of 1000 with a per-task breakdown of where the points went. Your first one is free.

No credit card needed.