If you spend more than 20 minutes every week updating, formatting, and saving your inventory report, you should automate it. Excel macros can handle all the repetitive steps — refreshing data, applying formats, and saving a dated copy — with a single click.

What This Macro Will Do

Step 1 — Enable the Developer Tab

File → Options → Customize Ribbon → check "Developer" → OK. The Developer tab now appears in your ribbon.

Step 2 — Record a Basic Macro First

Before writing VBA, record a macro to understand the structure:

1

Start recording

Developer tab → Record Macro → name it "RefreshReport" → OK.

2

Do your manual steps

Sort your data, apply any formatting, click through the steps you do every week.

3

Stop recording

Developer tab → Stop Recording. Excel has captured all your actions as VBA code.

Step 3 — The Full Automation Macro

Open the VBA editor (Developer → Visual Basic) and paste this code:

Sub WeeklyInventoryReport() ' Refresh all data connections ActiveWorkbook.RefreshAll Application.Wait (Now + TimeValue("0:00:03")) ' Sort inventory by Status column Dim ws As Worksheet Set ws = Sheets("Items") ws.Range("A1").CurrentRegion.Sort _ Key1:=ws.Range("K1"), Order1:=xlAscending, Header:=xlYes ' Save a dated copy Dim fileName As String fileName = "Inventory_Report_" & Format(Date, "YYYY-MM-DD") & ".xlsx" ActiveWorkbook.SaveCopyAs "C:\Reports" & fileName MsgBox "Report complete! Saved as: " & fileName End Sub
💡 Change C:\Reports\ to the actual folder path where you want to save reports. Make sure the folder exists before running.

Step 4 — Add a Button to Run It

Insert → Shapes → Rectangle. Draw a button, right-click → "Assign Macro" → select WeeklyInventoryReport. Now one click runs the whole process.

Step 5 — Schedule It with Windows Task Scheduler (Optional)

To run the report automatically every Monday at 8am:

Common Mistakes

⚠️ Macro security: Excel may block macros by default. Go to File → Options → Trust Center → Macro Settings → "Enable all macros" (or trust your specific file location).
⚠️ Save as .xlsm: Files with macros must be saved as .xlsm (Macro-Enabled Workbook). Regular .xlsx files strip out VBA code.

FAQ

Do I need to know VBA to use macros?
Not for basic automation. The Record Macro feature captures your actions without any coding. For more advanced automation like the scheduled report, copying the code above and adjusting the file paths is usually enough.
Can I email the report automatically?
Yes — add Outlook automation to your VBA macro. It can attach the saved report and send it to a distribution list. Alternatively, Power Automate (free with Microsoft 365) can monitor a folder and email new files automatically.

⚙️ Get the Inventory Dashboard Template

Free download — no sign-up required.

⬇ Download Free Template

Related Articles