Ravindra BagaleCourses & study guides मराठी Track your progress

15. Final Project: FreshGo Maharashtra Monthly Report

15.6 Stage 5 – A Small Macro

Steps in Excel

  1. Save as Excel Macro-Enabled Workbook (*.xlsm).
  2. Developer › Code › Visual Basic (Alt + F11) › Insert › Module › paste the macro below.
  3. Insert › Illustrations › Shapes › draw a button "Refresh & Export PDF" › right-click › Assign Macro… › RefreshAndExport.
  4. Test with Status filter/slicers cleared; check the PDF opens.
Sub RefreshAndExport()
    Dim pdfPath As String

    On Error GoTo ErrHandler
    ThisWorkbook.RefreshAll
    Application.CalculateUntilAsyncQueriesDone

    pdfPath = ThisWorkbook.Path & Application.PathSeparator & _
              "Blinkit_Dashboard_" & Format(Date, "dd-mm-yyyy") & ".pdf"

    ThisWorkbook.Worksheets("Dashboard").ExportAsFixedFormat _
        Type:=xlTypePDF, Filename:=pdfPath, Quality:=xlQualityStandard, _
        OpenAfterPublish:=True

    MsgBox "Dashboard refreshed and saved as:" & vbCrLf & pdfPath, vbInformation
    Exit Sub

ErrHandler:
    MsgBox "Could not finish: " & Err.Description, vbExclamation
End Sub

Worked example. Clicking the button on 30-09-2026 creates Blinkit_Dashboard_30-09-2026.pdf in the same folder as the workbook and opens it. If the workbook has never been saved, ThisWorkbook.Path is empty – save it first (the error handler reports the problem instead of crashing).

Ravindra Bagale's Tip

Many students save a macro in .xlsx and when they reopen the file the macro is gone. If there is a macro, always save as .xlsm, and put On Error GoTo in the code so the user gets a message they can understand. Keep a backup of the file before running a macro – Undo doesn't work after a macro.

Worked example — stage 5 a small macro

Why

Vikram Rao in Pune and Emma Clarke abroad both need a clear, repeatable way to use stage 5 a small macro on a Orbit Logistics sheet without breaking totals.

What

Stage 5 A Small Macro is the Excel idea this page teaches. We will walk one tiny example end to end.

How

  1. Open a blank sheet. In A1 type a short label for stage 5 a small macro.
  2. Enter a small made-up value for Vikram Rao using $ where money appears.
  3. Add a second value for Emma Clarke using $ so you see mixed currencies stay numeric.
  4. Apply the method from this lesson step by step (menu or formula as shown above).
  5. Check the result still works inside SUM or a simple check cell.

Formula / action

Follow the formula or ribbon steps shown in this lesson (keep values numeric).
Result: The demo cell shows the expected result for Orbit Logistics's sample row.
Meaning: Once stage 5 a small macro is correct on one row, copy the same pattern down the column.

Practice tasks (10+)

Try these on a blank sheet. Open a hint only if you are stuck. No quiz — just practice.

1. Rebuild the smallest example of stage 5 a small macro on a blank sheet for Skyline Clinics.

Hint: Use only the steps on this page. Keep numbers numeric.

2. Change one input for Aarti Kulkarni and confirm the result updates.

Hint: If the result is stuck, check absolute vs relative references.

3. Repeat the same steps with a £ or € value for Anna Kowalski.

Hint: Formatting must not break SUM.

4. Write the result meaning in one plain sentence next to the cell.

Hint: Imagine explaining it to a new joiners.

5. Add a second row and fill the method down.

Hint: Double-click the fill handle if the pattern is consistent.

6. Break the example on purpose, then fix it using this lesson.

Hint: Common break: text instead of a number.

7. Apply stage 5 a small macro to a 5-row made-up Skyline Clinics table.

Hint: Keep column headers clear.

8. Check your answer with a simple total or COUNT.

Hint: A wrong total usually means a format or key mismatch.

9. Swap ₹ and $ on one column and re-check totals.

Hint: Stored values stay the same; only the display changes.

10. List two mistakes beginners make with stage 5 a small macro.

Hint: Look back at the tip box on this page.

11. Teach the steps out loud in under one minute.

Hint: Why → What → How.

12. Save the sheet as SkylineClin_practice.xlsx.

Hint: Use a clear file name for class.

Quick revision cards

Three standalone cards. Each one explains the idea with its own example. Scan the QR to open this lesson.

Revision card 1: What is Stage 5 A Small Macro?
Card 1: What is Stage 5 A Small Macro? · Download PNG
Revision card 2: Tiny example — Stage 5 A Small Macro
Card 2: Tiny example — Stage 5 A Small Macro · Download PNG
Revision card 3: Checklist — Stage 5 A Small Macro
Card 3: Checklist — Stage 5 A Small Macro · Download PNG