15. Final Project: FreshGo Maharashtra Monthly Report
15.6 Stage 5 – A Small Macro
Steps in Excel
- Save as Excel Macro-Enabled Workbook (*.xlsm).
- Developer › Code › Visual Basic (Alt + F11) › Insert › Module › paste the macro below.
- Insert › Illustrations › Shapes › draw a button "Refresh & Export PDF" › right-click › Assign Macro… ›
RefreshAndExport. - 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.
Ravindra Bagale's Tip – मराठी
बरेच students macro .xlsx मध्ये save करतात आणि file पुन्हा उघडल्यावर macro गायब होतो. Macro असेल तर नेहमी .xlsm मध्ये save करा, आणि code मध्ये On Error GoTo ठेवून user ला समजेल असा message द्या. Macro चालवण्यापूर्वी एकदा file चा backup ठेवा – macro नंतर Undo काम करत नाही.
Ravindra Bagale's Tip – हिंदी
बहुत से students macro को .xlsx में save करते हैं और file दोबारा खोलने पर macro गायब होता है. Macro हो तो हमेशा .xlsm में save करो, और code में On Error GoTo रखकर user को समझ आने वाला message दो. Macro चलाने से पहले file का backup रख लो – macro के बाद Undo काम नहीं करता.
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
- Open a blank sheet. In A1 type a short label for stage 5 a small macro.
- Enter a small made-up value for Vikram Rao using $ where money appears.
- Add a second value for Emma Clarke using $ so you see mixed currencies stay numeric.
- Apply the method from this lesson step by step (menu or formula as shown above).
- 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).
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.


