By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
World of SoftwareWorld of SoftwareWorld of Software
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Search
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
Reading: I thought Excel macros were overkill until I built this one
Share
Sign In
Notification Show More
Font ResizerAa
World of SoftwareWorld of Software
Font ResizerAa
  • Software
  • Mobile
  • Computing
  • Gadget
  • Gaming
  • Videos
Search
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Have an existing account? Sign In
Follow US
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
World of Software > News > I thought Excel macros were overkill until I built this one
News

I thought Excel macros were overkill until I built this one

News Room
Last updated: 2025/09/27 at 7:45 AM
News Room Published 27 September 2025
Share
SHARE

I used to think Excel macros were overkill because I had to go through the trouble of recording steps and tweaking code for something I could easily do manually. Then I was tasked with standardizing report layouts (a deceptively simple task), but I quickly realized how tedious it would be since there were many sheets. That’s when I looked into macros and discovered I had them all wrong.

With one click, the macro I created saved me hours of work. Once I got a taste of how a well-executed macro enhances my workflow, I was hooked. Now I rely on them so much that I sometimes use macros instead of formulas.

Why I thought macros were too much

And why I was wrong

Like many, I avoided macros because I thought the learning curve was too steep. I also thought they were unnecessarily complex to build and required advanced programming skills. Sure, you can easily record a macro and use one without coding, but then it would be sheet-specific and difficult to scale due to it having hard-coded cell references, file paths, or UI elements.

This meant that I would definitely need to learn some Visual Basic for Applications (VBA) so that I could refactor the code of the recorded macros into something flexible and reusable. Luckily, recording a macro is very easy. Furthermore, VBA is relatively easy and intuitive, with its readable syntax and the fact that it works within Excel, providing instant feedback.

On top of helping me refactor recorded macros, knowing VBA helps me inject some error handling into them. Furthermore, if I get stuck and need help with bugs, there is a helpful online community that can assist me in resolving them. I had every reason to learn it—so I did.

The macro that changed everything

Hours of work done with a single click

The 'Code' section of the 'Developer' tab in Excel

When the aforementioned workbook was sent to me, it had over 20 sheets that needed to be formatted and exported. I knew more were coming down the line, and that I would hate manually doing it every time. It was time to become a macro wizard.

Setting up the macro took a lot of trial and error, especially when it came to getting the VBA code right (thanks, Stack Overflow!). Since I’m already familiar with coding, I just had to look at a VBA crash course video on YouTube to get to grips with it. What I built in the end was efficient and easy to use.

Enabling the Developer tab

Creating a macro with VBA requires accessing the Developer tab, which is not visible by default. To enable it, click File -> Options -> Customize Ribbon. In the Main Tabs section, check Developer and click OK.

Customizing the ribbon in Excel

Creating the macro and refining

To create the macro, I clicked Macros in the Code command group of the ribbon to open the Macros window. I gave the macro a name and clicked Create to open the VBA editor window. Afterward, I wrote the code, saved the script (Ctrl + S), and closed the editor.

Over the course of the weeks, I refined the script. It started just formatting one sheet at a time, but this also got tedious. Now it formats all Excel sheets in a workbook with a single click.

Below is the final code with comments included to explain what each section does. I have removed some lines, such as those that apply the color scheme of the company I worked for and its logo in the header, to keep the script relatively short.

        Sub FormatAndExportSheets()
   Dim ws As Worksheet
   Dim rng As Range
   Dim pdfPath As String
   Dim cell As Range

   'Setting the desired font and color scheme
   Const FONT_NAME As String = "Calibri"
   Const FONT_SIZE As Integer = 11
   Const HEADER_FONT_SIZE As Integer = 14
   

   'Setting PDF export folder
   pdfPath = ThisWorkbook.Path & "Formatted " + "Sheets"
   If Dir(pdfPath, vbDirectory) = "" Then MkDir pdfPath

   'Looping through each sheet
   For Each ws In ThisWorkbook.Worksheets
       With ws
           'Standardizing the column widths
           .Cells.ColumnWidth = 15

           'Applying font settings
           .Cells.Font.Name = FONT_NAME
           .Cells.Font.Size = FONT_SIZE
           
           'Formatting the header (first row)
           Set headerRange = .Range("A1:" & .Cells(1, .UsedRange.Columns.Count).Address)
           With headerRange
               .Font.Bold = True
               .Font.Size = HEADER_FONT_SIZE
               .Interior.Color = RGB(220, 230, 241) 'Giving the header a light blue background
               .Borders.Weight = xlMedium
           End With

           'Applying number formatting
           For Each cell In .UsedRange
               If IsNumeric(cell.Value) Then
                   If cell.Value > 1 Then
                       cell.NumberFormat = "$
                   ElseIf cell.Value <= 1 And cell.Value >= 0 Then
                       cell.NumberFormat = "0.00%" 'Formatting the percentages
                   End If
               End If
           Next cell

           'Exporting the sheet to a PDF
           .ExportAsFixedFormat Type:=xlTypePDF, _
               Filename:=pdfPath & .Name & ".pdf", _
               Quality:=xlQualityStandard, _
               IncludeDocProperties:=True, _
               IgnorePrintAreas:=False, _
               OpenAfterPublish:=False
       End With
   Next ws

   'Displaying a success message
   MsgBox "All sheets formatted and saved as PDFs in: " & pdfPath, vbInformation
End Sub

Basically, the script loops through each sheet in the workbook to format the cells that have values. Specifically, it standardizes the column widths and fonts, as well as formats numerical values into either currencies or percentages.

Afterward, it exports each sheet as a PDF to a folder named Formatted Sheets. If the folder doesn’t exist, it will create one—this is the error checking you can’t do with recorded macros alone. Finally, it displays a success message upon successfully completing the formatting.

Using the macro

Before I used the macro, I assigned it a shortcut. Some people get creative by creating a GUI button for it, but a shortcut works if you don’t have many macros.

To do that, open the Macros window, select the macro, and click Options. Under Shortcut key, press the key to use with Ctrl—I chose Ctrl + J—and click OK. When choosing the key, just make sure it doesn’t already belong to other Excel shortcuts to avoid conflicts.

Setting a shortcut for a macro in Excel

After hitting the shortcut, the macro does its thing, and you will get a message saying the sheets have been formatted and saved as PDFs. And if you check the folder specified in the script, you will find the formatted PDFs there. Keep in mind that the PDFs will be overwritten every time you run the macro.

I’ve created many more macros ever since

That one macro reduced a task that would have taken me hours down to minutes, while ensuring consistent results every time. More importantly, it completely changed my stance on macros. They aren’t overkill.

I have since built additional macros that handle everything from formatting and calculations to data validation and data cleaning. Sure, Power Query can easily clean up your data, for example, but only with macros do you get full control over Excel features to automate repetitive tasks.

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter Email Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article WIN iRobot Roomba Plus 505 & Roomba Max 705 robot vacuums!  | Stuff
Next Article China to release third round of trade-in subsidies for consumers in July · TechNode
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow

Latest News

How to Build a Social Media Marketing Strategy in 2025 Effectively
Computing
Premier League Soccer: Stream Man City vs. Burnley Live From Anywhere
News
Best Apple Deals of the Week: First Sales Hit Official iPhone 17 Cases, Plus Save on Charging Accessories and More
News
How to Ask ChatGPT to Rewrite Something? |
Computing

You Might also Like

News

Premier League Soccer: Stream Man City vs. Burnley Live From Anywhere

10 Min Read
News

Best Apple Deals of the Week: First Sales Hit Official iPhone 17 Cases, Plus Save on Charging Accessories and More

9 Min Read
News

8 Companies Poised to Soar From Nvidia and OpenAI’s $100 Billion Alliance

11 Min Read
News

Anthros Chair Review: A Comfortable Seat That Improves Posture and Relieves Pain

4 Min Read
//

World of Software is your one-stop website for the latest tech news and updates, follow us now to get the news that matters to you.

Quick Link

  • Privacy Policy
  • Terms of use
  • Advertise
  • Contact

Topics

  • Computing
  • Software
  • Press Release
  • Trending

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

World of SoftwareWorld of Software
Follow US
Copyright © All Rights Reserved. World of Software.
Welcome Back!

Sign in to your account

Lost your password?