Excel Macros That Save Hours — Hide Sheets & Send Reports in One Click
Two VBA macros for daily analyst work — toggle very-hidden sheets by tab color, and draft Outlook emails with the workbook attached and body populated from a template sheet.
Excel macros are great for automating repetitive tasks and extending what the app does out of the box. Here are two custom macros I rely on — one for hiding calculation sheets, one for drafting recurring report emails.
I'm not a macro expert. A former colleague got me started, and the email macro below is something I learned from him directly. Sharing it here in case it helps your day-to-day work too.
Macros in this post
- Hide or unhide multiple Excel sheets at once — by yellow tab color
- One-click email send — to selected recipients, with the workbook attached
Copy the code into your PERSONAL.XLSB file. If you don't have one yet, this tutorial shows how to create it.
Once set up, your personal macro workbook will look something like this (you can ignore the other code in the screenshot for now):
Hide or unhide multiple Excel sheets at once
Analysts and accountants often keep helper sheets for calculations, metadata, or staging — sheets stakeholders don't need to see. Hiding and unhiding them manually is slow and easy to forget.
This macro toggles every sheet whose tab color matches a defined yellow (65535), switching between visible and very hidden (xlSheetVeryHidden).
Code
CONST TABCOLOR AS LONG = 65535
'65535 is the color code for Yellow
Sub VeryHidden_Hide_Unhide_Toggle()
'Hide all sheets with yellow colored tab (if currently visible)
'Unhide all sheets with yellow colored tab (if currently invisible)
Dim ws As Object
'Use object instead of Worksheet
'Loop through sheets and hide/unhide yellow tabs
For Each ws In ActiveWorkbook.Sheets
If ws.Tab.Color = TABCOLOR Then
If ws.Visible = xlSheetVeryHidden Then
ws.Visible = xlSheetVisible
Else
ws.Visible = xlSheetVeryHidden
End If
End If
Next ws
End SubRunning the macro
Step 1: Open the workbook where you want to run the macro. If Excel shows Macros have been disabled, click Enable Content.
Step 2: Below is a preview of the sheets currently visible to stakeholders.
Step 3: Open the macro list via View → Macros → View Macros, or press Alt + F8.
Step 4: Select VeryHidden_Hide_Unhide_Toggle from PERSONAL.XLSB and click Run.
Step 5: Yellow-tab sheets appear immediately. Run the same macro again to hide them.
One-click email send to selected recipients
When you send the same report on a schedule — daily, weekly, monthly — most fields are predictable: recipients, subject, body range, attachment. A macro can open a pre-filled Outlook draft so you only review and hit Send.
This example attaches the active workbook, pulls the subject from cell D1, the body from range D2:M40, and the sender name from document properties (useful for automating the Regards line).
Code
Sub Daily_Sales_Report()
ActWB = ActiveWorkbook.Name
ActWBP = ActiveWorkbook.Path
ActiveWorkbook.Save
ActiveWorkbook.Sheets("Email").Visible = True
ActiveWorkbook.Sheets("Email").Activate
Range("D34") = ActiveWorkbook.BuiltinDocumentProperties("Last Author")
'This line dynamically generate name. Helpful for email Regards section automation
ActiveSheet.Range("D2:M40").Select
'The range we want to show in email body
With ActiveSheet.MailEnvelope
.Item.To = "karim@domain.com"
.Item.CC = "john@domain.com; george@domain.com"
.Item.BCC = ""
.Item.Subject = Sheets("Email").Range("D1")
'Email subject taken from content present in this cell
att = ActWBP & "\" & ActWB
.Item.Attachments.Add att
.Item.SentOnBehalfOfName = "mehedi.farazi@domain.com"
'Email sent from which ID. Helpful if you have multiple email configured.
.Item.Save
.Item.Display
End With
ActiveWorkbook.Close SaveChanges:=False
End SubReplace the To, CC, SentOnBehalfOfName, sheet name, and cell ranges with your own setup.
Running the macro
Step 1: Open the workbook and enable macros if prompted.
Step 2: The Email sheet defines what goes into the draft — subject in D1, body in D2:M40, sender name in D34 via built-in document properties.
Step 3: Open macros with Alt + F8 or View → Macros → View Macros.
Step 4: Select Daily_Sales_Report and click Run.
Step 5: Outlook opens a draft in your Drafts folder with the attachment and populated body. Review and send. In this example, Mehedi was pulled automatically from document properties.
Hope this was useful. More posts from the archive coming soon — Python, Snowflake, and Tableau notes are next in the queue.