Bird
Raised Fist0
Excelspreadsheet~8 mins

Running macros in Excel - Dashboard Guide

Choose your learning style10 modes available
Dashboard Mode - Running macros
Dashboard Goal

Help users run macros easily to automate tasks like formatting and calculations in Excel.

Sample Data
ItemQuantityPrice
Apples100.5
Bananas50.3
Oranges80.6
Grapes150.4
Pears70.55
Dashboard Components
  • KPI Card: Total Quantity
    Formula: =SUM(B2:B6)
    Result: 45
  • KPI Card: Total Sales
    Formula: =SUMPRODUCT(B2:B6,C2:C6)
    Result: 21.15
  • Button: Run Macro to Format Table
    Description: When clicked, runs a macro that bolds headers, colors header background light blue, and formats price column as currency.
  • Button: Run Macro to Calculate Discounts
    Description: When clicked, runs a macro that adds a new column "Discounted Price" with 10% off price for each item.
  • Table: Data Table with Discounted Price Column
    Initially empty in column D, filled after running discount macro.
Dashboard Layout
+----------------------+----------------------+
| Total Quantity (KPI) | Total Sales (KPI)    |
+----------------------+----------------------+
| [Run Format Macro]    | [Run Discount Macro] |
+-------------------------------------------+
| Data Table with Items, Quantity, Price,   |
| and Discounted Price (after macro runs)   |
+-------------------------------------------+
Interactivity

Clicking the Run Format Macro button applies formatting to the data table headers and price column.

Clicking the Run Discount Macro button adds the "Discounted Price" column with prices reduced by 10%. This updates the data table to show new values.

Self Check

After clicking the Run Discount Macro button, what is the discounted price for Grapes?

Answer: Grapes price is 0.4, so discounted price = 0.4 * 0.9 = 0.36

Key Result
Dashboard to run macros that format data and calculate discounted prices automatically.

Practice

(1/5)
1. What is the easiest way to run a macro in Excel without writing any code?
easy
A. Press Alt + F8 and select the macro to run
B. Open the Visual Basic Editor and type the macro name
C. Right-click a cell and choose 'Run Macro'
D. Use the formula bar to enter the macro name

Solution

  1. Step 1: Understand how to run macros easily

    Excel provides a shortcut Alt + F8 to open the macro list quickly.
  2. Step 2: Use Alt + F8 to select and run

    After pressing Alt + F8, you can pick the macro and click Run to execute it.
  3. Final Answer:

    Press Alt + F8 and select the macro to run -> Option A
  4. Quick Check:

    Alt + F8 runs macros easily [OK]
Hint: Use Alt + F8 to open and run macros fast [OK]
Common Mistakes:
  • Trying to run macros from the formula bar
  • Thinking right-click menu runs macros
  • Confusing Visual Basic Editor with macro running
2. Which of the following is the correct way to assign a macro to a button in Excel?
easy
A. Drag the macro from Visual Basic Editor onto the button
B. Double-click the button and type the macro name
C. Insert a button from Developer tab, then right-click and choose 'Assign Macro'
D. Use the formula =RunMacro() on the button

Solution

  1. Step 1: Insert a button from Developer tab

    Excel lets you add buttons via Developer > Insert > Form Controls.
  2. Step 2: Assign macro by right-clicking the button

    Right-click the button and select 'Assign Macro' to link your macro.
  3. Final Answer:

    Insert a button from Developer tab, then right-click and choose 'Assign Macro' -> Option C
  4. Quick Check:

    Assign macro via button right-click [OK]
Hint: Right-click button to assign macro quickly [OK]
Common Mistakes:
  • Trying to drag macros onto buttons
  • Using formulas to run macros
  • Double-clicking button does not assign macro
3. Given this VBA macro code:
Sub ShowMessage()
  MsgBox "Hello, World!"
End Sub

What happens when you run this macro?
medium
A. A message box appears showing 'Hello, World!'
B. The text 'Hello, World!' is entered in the active cell
C. Nothing happens because MsgBox is incorrect
D. Excel crashes due to syntax error

Solution

  1. Step 1: Understand the MsgBox function

    MsgBox displays a popup message box with the given text.
  2. Step 2: Running ShowMessage macro shows the message

    When run, the macro triggers MsgBox to show 'Hello, World!'.
  3. Final Answer:

    A message box appears showing 'Hello, World!' -> Option A
  4. Quick Check:

    MsgBox shows popup message [OK]
Hint: MsgBox shows popup messages in macros [OK]
Common Mistakes:
  • Thinking MsgBox writes to cells
  • Assuming MsgBox is a syntax error
  • Expecting no output from macro
4. You wrote this macro:
Sub AddNumbers()
  Range("A1") = Range("A1") + Range("B1")
End Sub

But running it gives an error. What is the likely problem?
medium
A. You must use Cells() instead of Range() to add numbers
B. Range references need to be declared as variables first
C. The macro syntax is invalid because of missing parentheses
D. The macro tries to add text values causing a type mismatch error

Solution

  1. Step 1: Check the data types in cells A1 and B1

    If either cell contains text, adding causes a type mismatch error.
  2. Step 2: Understand VBA does not auto-convert text to numbers

    VBA needs numeric values to add; text causes error.
  3. Final Answer:

    The macro tries to add text values causing a type mismatch error -> Option D
  4. Quick Check:

    Adding text causes type mismatch error [OK]
Hint: Ensure cells contain numbers before adding in macros [OK]
Common Mistakes:
  • Assuming Range() needs variable declaration
  • Thinking syntax error is due to parentheses
  • Believing Cells() must replace Range() always
5. You want to create a macro that clears the contents of cells A1 to A5 and then enters the text 'Done' in cell A6. Which VBA code correctly does this?
hard
A. Sub ClearAndDone() Clear Range("A1:A5") Range("A6") = "Done" End Sub
B. Sub ClearAndDone() Range("A1:A5").ClearContents Range("A6") = "Done" End Sub
C. Sub ClearAndDone() Range("A1:A5").Clear Range("A6").Value = "Done" End Sub
D. Sub ClearAndDone() Range("A1:A5").ClearContents() Range("A6").Text = "Done" End Sub

Solution

  1. Step 1: Use ClearContents to clear cells A1 to A5

    ClearContents removes only the data, keeping formatting intact.
  2. Step 2: Assign text 'Done' to cell A6 correctly

    Using Range("A6") = "Done" sets the cell value properly.
  3. Final Answer:

    Sub ClearAndDone() Range("A1:A5").ClearContents Range("A6") = "Done" End Sub -> Option B
  4. Quick Check:

    ClearContents + assign text = correct macro [OK]
Hint: Use ClearContents to clear cells, assign text directly [OK]
Common Mistakes:
  • Using Clear instead of ClearContents (clears formatting too)
  • Wrong syntax like Clear Range(...)
  • Using .Text property to assign cell value
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard