Home Blog VBA Macros Guide

How to Automate Your Daily Reports
with VBA Macros

📅 January 22, 2026 ⏱️ 15 min read ✍️ Learn Make Easy Team 🤖 VBA
Take the Free Excel Course → All Articles
📋 Table of Contents

    Are you spending 30–60 minutes every day creating the same report — copying data, formatting cells, applying filters, and saving files? If yes, VBA Macros can give you that time back.

    VBA (Visual Basic for Applications) is Excel's built-in programming language. With it, you can record and automate any repetitive task — and run it with a single click. You do not need to be a programmer to get started.

    In this article, you will learn — step by step — how to record your first macro, understand the code it generates, edit it, and use it to automate your daily reports.

    What is a VBA Macro?

    A Macro is a recorded sequence of actions in Excel. When you record a macro, Excel watches what you do and writes the VBA code for you automatically. You can then replay that recorded sequence any time — instantly.

    Think of it like this: instead of doing 20 steps manually every morning, you press one button and Excel does all 20 steps for you in under 3 seconds.

    Real-world example: Every Monday morning you open a sales file, filter for "This Week", calculate totals for each region, copy the summary to a new sheet, format it, and save a copy with today's date. A macro can do all of this automatically while you drink your morning chai ☕

    Before You Start — Enable the Developer Tab

    The Developer tab is hidden by default. You need it to record and run macros.

    Step

    Enable the Developer Tab

    1. Click File → Options
    2. Click Customize Ribbon on the left
    3. On the right panel, find Developer in the list
    4. Check the box next to it
    5. Click OK

    The Developer tab will now appear in your Ribbon between View and Help.

    ⚠️ Important: Files containing macros must be saved as .xlsm (Excel Macro-Enabled Workbook) — not .xlsx. If you save as .xlsx, all macros will be lost. Excel will warn you about this when you save.

    Step 1 — Record Your First Macro

    The fastest way to create a macro is to simply record what you do. Excel writes the code for you.

    How to Record

    Recording a Macro in Excel

    1. Click the Developer tab
    2. Click Record Macro
    3. Give your macro a name — e.g., FormatDailyReport (no spaces allowed)
    4. Assign a shortcut key — e.g., Ctrl + Shift + R
    5. Choose where to store it: This Workbook (recommended)
    6. Click OK — recording starts now
    7. Perform your actions: format headers, apply bold, add borders, etc.
    8. When done, click Stop Recording on the Developer tab

    Your macro is saved. Press the shortcut key to replay it instantly.

    💡 Pro Tip: Before recording, plan exactly what steps you want to record. Every click, every scroll, every selection gets recorded. Keep it clean and deliberate — avoid unnecessary mouse movements.

    Step 2 — View and Understand the VBA Code

    After recording, Excel generates VBA code automatically. Let us open it and understand what it looks like.

    How to Open

    Open the VBA Editor

    1. Press Alt + F11 — this opens the VBA Editor (also called VBE)
    2. In the left panel, expand your workbook
    3. Double-click Module1 — your recorded macro code appears

    Here is what a typical recorded macro looks like — let us say you recorded formatting a header row:

    ' This macro formats the header row of your report Sub FormatDailyReport() ' Select the header row Range("A1:F1").Select ' Apply bold formatting Selection.Font.Bold = True ' Set background colour to red Selection.Interior.Color = RGB(239, 68, 68) ' Set font colour to white Selection.Font.Color = RGB(255, 255, 255) ' Set font size to 12 Selection.Font.Size = 12 ' Auto-fit all columns Cells.EntireColumn.AutoFit End Sub

    Every macro starts with Sub MacroName() and ends with End Sub. Everything in between is the list of instructions Excel follows.

    Understanding the code:
    Range("A1:F1").Select — selects cells A1 to F1
    Selection.Font.Bold = True — makes the selected cells bold
    RGB(239, 68, 68) — sets a red colour using Red, Green, Blue values
    Cells.EntireColumn.AutoFit — auto-fits all column widths

    Step 3 — Write a Macro from Scratch

    Now let us write a real, practical macro manually. This one will automate a daily report — it will format data, add a date stamp, and save a copy automatically.

    Practical Macro

    Daily Report Automation Macro

    This macro does 6 things automatically:

    1. Formats the header row
    2. Auto-fits all columns
    3. Adds today's date in cell H1
    4. Sorts data by column B (Sales) — highest first
    5. Saves a copy with today's date in the file name
    6. Shows a confirmation message
    Sub AutomateDailyReport() '--- Step 1: Format the header row --- With Range("A1:F1") .Font.Bold = True .Font.Size = 12 .Font.Color = RGB(255, 255, 255) .Interior.Color = RGB(239, 68, 68) .HorizontalAlignment = xlCenter End With '--- Step 2: Auto-fit all columns --- Cells.EntireColumn.AutoFit '--- Step 3: Add today's date in H1 --- Range("H1").Value = "Report Date: " & Format(Now(), "DD-MMM-YYYY") Range("H1").Font.Bold = True '--- Step 4: Sort by Sales column (B) highest first --- Dim lastRow As Long lastRow = Cells(Rows.Count, "A").End(xlUp).Row Range("A1:F" & lastRow).Sort _ Key1:=Range("B1"), _ Order1:=xlDescending, _ Header:=xlYes '--- Step 5: Save a copy with today's date --- Dim savePath As String savePath = ThisWorkbook.Path & "\" & _ "DailyReport_" & Format(Now(), "YYYY-MM-DD") & ".xlsx" ThisWorkbook.SaveCopyAs savePath '--- Step 6: Show confirmation message --- MsgBox "✅ Report ready! Saved as: " & savePath, _ vbInformation, "Daily Report Done" End Sub
    💡 Pro Tip: The line Cells(Rows.Count, "A").End(xlUp).Row finds the last row with data automatically — so your macro works no matter how many rows your data has. This is one of the most useful VBA tricks for dynamic data.

    Step 4 — Run Your Macro

    There are 4 ways to run a macro in Excel:

    MethodHow to Do ItBest For
    Keyboard ShortcutPress the shortcut you assigned (e.g. Ctrl+Shift+R)Daily use — fastest
    Developer TabDeveloper → Macros → Select → RunRunning any saved macro
    Button on SheetInsert → Shapes → right-click → Assign MacroSharing with non-technical users
    VBA EditorAlt+F11 → click inside Sub → press F5Testing during development
    💡 Pro Tip: For shared workbooks, add a button on the sheet. Anyone can click it — they don't need to know about macros or shortcut keys.

    Step 5 — Add a Button to Run the Macro

    Easy Access

    Create a Macro Button on Your Sheet

    1. Go to Developer tab → Insert → Button (Form Control)
    2. Draw the button on your sheet by clicking and dragging
    3. The Assign Macro dialog opens automatically
    4. Select your macro name → click OK
    5. Right-click the button → Edit Text → rename it: "Generate Report"

    Now anyone can click this button to run the macro — no knowledge of VBA needed.

    Step 6 — Loop Through Data Automatically

    One of VBA's most powerful features is looping — going through each row and doing something. Here is a practical loop that highlights rows where sales are below target:

    Sub HighlightBelowTarget() Dim i As Long Dim lastRow As Long Dim target As Long target = 50000 ' Set your sales target here lastRow = Cells(Rows.Count, "A").End(xlUp).Row ' Loop through each data row (starting from row 2) For i = 2 To lastRow If Cells(i, 2).Value < target Then ' Highlight the entire row in light red Rows(i).Interior.Color = RGB(255, 220, 220) Else ' Clear any existing colour for rows above target Rows(i).Interior.ColorIndex = xlNone End If Next i MsgBox "Done! Rows below ₹50,000 target are highlighted.", _ vbInformation End Sub
    What this does: It checks column B (Sales) for every row. If sales < 50,000, it colours that row light red. If sales are on target or above, it clears any colour. The loop repeats for every row automatically.

    Step 7 — Schedule Your Macro to Run Automatically

    You can make a macro run automatically when you open the workbook — so your report is ready the moment you open the file every morning.

    ' This goes in the "ThisWorkbook" module — NOT in a Module ' Double-click "ThisWorkbook" in the VBA editor to find it Private Sub Workbook_Open() ' This runs automatically every time the file is opened Call AutomateDailyReport End Sub
    ⚠️ Important: This code must go inside ThisWorkbook module — not in Module1. In the VBA editor left panel, look for "ThisWorkbook" and double-click it. Paste the code there.
    💡 Pro Tip: Other automatic triggers you can use:
    Workbook_BeforeClose — runs before the file closes
    Workbook_BeforeSave — runs before every save
    Worksheet_Change — runs when any cell value changes

    Common VBA Mistakes to Avoid

    1. Saving as .xlsx instead of .xlsm — All macros are deleted. Always save as .xlsm.
    2. Using Select and Selection everywhere — Recorded macros use Select a lot. Professional VBA avoids it. Instead of Range("A1").Select / Selection.Bold = True, write Range("A1").Bold = True directly.
    3. Hardcoding the last row number — Never write Range("A1:A500"). Use Cells(Rows.Count,"A").End(xlUp).Row to find it dynamically.
    4. Not handling errors — If something goes wrong, the macro crashes. Add On Error GoTo ErrorHandler at the top of important macros.
    5. No comments in code — Always add comments (lines starting with ') to explain what each section does. Future you will thank present you.

    🎯 Summary — Your VBA Automation Checklist

    Here is everything you need to automate your daily reports with VBA:

    1. Enable the Developer tab — File → Options → Customize Ribbon
    2. Record a macro — Developer → Record Macro → do your steps → Stop
    3. Open the VBA editor — Alt+F11 to view and edit the code
    4. Edit the recorded code — Clean it up, remove unnecessary Select statements
    5. Write your own macro — Format, sort, save, loop through data
    6. Add a button — Developer → Insert → Button → Assign Macro
    7. Auto-run on open — Put code in ThisWorkbook → Workbook_Open
    8. Save as .xlsm — Never .xlsx for files with macros

    Frequently Asked Questions

    What is a VBA Macro in Excel?+
    A VBA Macro is a recorded or written sequence of instructions Excel executes automatically. It automates repetitive tasks — formatting, sorting, saving files — that would otherwise take minutes every day.
    Do I need programming experience to learn Excel VBA?+
    No. Excel's Macro Recorder writes VBA code automatically as you work. You can start using macros without writing a single line of code.
    What is the difference between a Macro and VBA?+
    A Macro is the recorded action sequence. VBA (Visual Basic for Applications) is the programming language used to write and edit macros. The Macro Recorder uses VBA behind the scenes.
    How do I run a VBA Macro in Excel?+
    4 ways: 1) Press assigned shortcut (e.g. Ctrl+Shift+R). 2) Developer tab → Macros → Run. 3) Click a button on the sheet. 4) Alt+F11 → click inside Sub → press F5.
    Can VBA macros work on Mac?+
    Yes, with limitations. Most basic automation macros work fine on both Windows and Mac Excel.
    📚 Related Resources:  Excel for Beginners  |  Advanced Excel Formulas  |  Top 10 Excel Formulas  |  Data Cleaning in Excel

    Want to master VBA from scratch?

    Our VBA & Macros Basics course covers everything — from your first macro to building full automation tools — step by step with real projects.