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

Record simple macros

  1. 1View › Macros › Record Macro.
  2. 2Macro name: FormatHeader. Store macro in: This Workbook. OK.
  3. 3Do the steps once: select A1:D1, then Ctrl+B for bold.
  4. 4View › Macros › Stop Recording.

The recorder writes VBA for each thing you do between Record Macro and Stop Recording. Run the macro later and Excel repeats those steps.

What the MO-211 task asks

A recording task in our MO-211 practice exams gives the name, where to store it and the steps: “Record a macro named FormatHeader (store it in this workbook) that selects A3:F3 on the Log sheet, makes it bold, and fills it with Light Blue … Stop recording when done.”

Several add an instruction for afterwards: “Undo afterwards so the child fares are back — the grader marks the macro, not the deletion.” Our grader opens the macro itself: that a module exists, that a macro of that name exists, and that its code does the step (ClearContents for clearing, Visible for hiding a sheet, Hidden for hiding columns).

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
Record it
Do this
  1. 1View › Macros › Record Macro.
  2. 2Name FormatHeader, This Workbook, OK.
  3. 3Select A1:D1, Ctrl+B for bold.
  4. 4View › Macros › Stop Recording.
Excel showsView › Macros › View Macros lists FormatHeader

The recorder stored the steps as a macro in a new module in this workbook.

Run it
Do this
  1. 1Clear the bold from A1:D1.
  2. 2View › Macros › View Macros, FormatHeader, Run.
Excel showsA1:D1 bold again; E1 untouched

The macro selects exactly the range you selected while recording.

Saving it
Do this
  1. 1File › Save As, type Excel Macro-Enabled Workbook (.xlsm).
Excel showsThe .xlsm keeps the macro; a plain .xlsx would not

A .xlsx file cannot hold VBA, so saving as .xlsx drops the macro.

In the video
Do this
  1. 1Record Macro, FormatHeader, This Workbook.
  2. 2Select A1:D1, Ctrl+B.
  3. 3Stop Recording.
Excel showsFormatHeader in View Macros

The first example, done in Excel on the same sheet.

Watch it done in Excel

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

Exam traps

Store macro in: Personal Macro Workbook

The macro then lives in your own hidden workbook, not in the exam file, and the grader finds no module there. Choose This Workbook.

Forgetting to stop

Everything after Record Macro is recorded until you stop, including the clicks that come after the task.

Saving as .xlsx

A macro cannot be stored in a .xlsx: it is lost when the file is saved that way. Exam files with macros are .xlsm.

Leaving the change when the task says undo it

If the task says to undo the macro's effect afterwards, do it: the sheet is checked in its original state, and the macro is still marked.

FAQ

Do I need the Developer tab?

No. View › Macros has Record Macro, Stop Recording and View Macros, which is all a recording task needs.

Where does the macro go?

Into a module in this workbook; the first module is named Module1. The grader checks that the workbook has one.

Can I see the code it wrote?

Yes: Alt+F11 opens the Visual Basic Editor, and the recorded macro is in a module under this workbook.

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.