Ravindra BagaleCourses & study guides

12. Macros and VBA

12.3 Running Macros: Button, Shortcut and the Macros Dialog

Steps in Excel

  1. Macros dialog: Developer › Code › Macros (Alt + F8) › select › Run. Options… sets or changes the shortcut key.
  2. Shortcut key: use Ctrl + Shift + letter – plain Ctrl + letter can override Excel shortcuts like Ctrl + C.
  3. Button (Form Control): Developer › Controls › Insert › Form Controls › Button › draw it › the Assign Macro dialog opens › choose FormatDailyReport › OK › right-click › Edit Text "Format Report".
  4. Any shape as a button: Insert › Illustrations › Shapes › draw a rounded rectangle › type text › right-click › Assign Macro…
  5. Quick Access Toolbar: File › Options › Quick Access Toolbar › Choose commands from: Macros › Add › Modify… to pick an icon.

Worked example. On the Report sheet Zoya adds three shape-buttons: Format Report, Split by City, Combine Sheets, each assigned to a macro from 12.12 – the Nashik store manager can run them without opening the VBA Editor.

Ravindra Bagale's Tip

If you give a macro the shortcut Ctrl + C or Ctrl + V, Excel's copy-paste stops working – and many students can't figure out why! Always use Ctrl + Shift + a letter. Write a clear name on the button ("Format Report"), not "Button 1" – the user should know what will happen.

Practice task

Assign your FormatHeader macro to a shape button and to the Quick Access Toolbar. Change its shortcut to Ctrl + Shift + F from the Macros dialog.