Last updated on January 9, 2025 By Victor Chan
Have you ever wished you could save hours of work in Excel with just a few clicks?
I use Excel all the time and like to think of Excel as a powerful sports car. But it’s one that many people drive in first gear on a narrow bendy road with a low speed limit.
For many years, I used Excel in first gear. I’d go to work on my spreadsheets, doing repetitive tasks with the mouse and keyboard over and over again.
It was frustrating. But it doesn’t have to be that way. Let me show you how macros and VBA can help you get work done much faster in Excel.
Watch every step in my YouTube video tutorial.
Download FREE Excel Workbook
Step 1: Sign up for free → Click Here
Step 2: Log in for access → Click Here
Step 3: Download file from → This Page
(Filename:Recorded_Macros.zip)
Are you new to Excel VBA Macros?
• Find out how to enable and disable macros in Excel with this tutorial
• Save time and effort by copying VBA macros from one workbook to another with these instructions
First, what is a macro?
Imagine you’re the chef of a busy kitchen. You’re responsible for everything: prepping, cooking, and cleaning up all by yourself. Exhausting, isn’t it?
But what if you had help? Imagine a team of smart little sidekicks called macros. They watch and copy your every move. Once you show them how to do something, they’ll remember it forever.
They take care of repetitive tasks so you can focus on what matters most, or just relax.
That’s what macros can do for you in Excel. They record your actions and repeat them perfectly, saving you time and effort. And they’re not hard to learn.
Let’s start with a simple spreadsheet example. Imagine you’re working with a spreadsheet for the Victor Consulting Company, containing 100 rows of client data, including sales forecasts.
When reviewing with your team, you might want to highlight specific rows to make them stand out. For instance, let’s make them bold, italic, and add an orange fill.
If you just need to do it once, that’s fine. But you do this regularly, and it becomes repetitive. You could use the Format Painter, but it’s not perfect. If you want to undo the highlight or change it, you have to go back and manually adjust each row.
Here’s where macros shine. This is an ideal candidate for automation. Let’s record macros to:
Step 1: Record the Highlight Macro
Now let’s test it. Select a row, press CTRL + SHIFT + H, and watch the magic happen as the highlight is applied.
Step 2: Record the Unhighlight Macro
Test this macro too. Press CTRL + SHIFT + J, and the row will return to its original formatting.
Let’s go back to the kitchen analogy.
Imagine you have two robots. One always prepares steaks, and the other always makes salmon. They’re helpful, but they only follow a fixed set of instructions. What if you could upgrade these robots to do even more?
Such as handle orders for steak and fries, or salmon and vegetables
That’s where VBA comes in. VBA, or Visual Basic for Applications, is the coding language that powers macros.
It lets you rewire your macros and teach them new tricks. With VBA, you can customize tasks instead of sticking to what was recorded.
For example, you could upgrade the steak robot to also make fries, so it handles steak and fries orders. The salmon robot could be enhanced to prepare salmon with vegetables.
But why stop there? With VBA, you can make a third, smarter robot that adapts based on what’s needed. If the customer wants steak, it makes steak and fries. If they ask for salmon, it makes salmon and vegetables.
Back in Excel, this means upgrading your macros to expand their abilities and adding logic to make them more versatile. For instance, you can use VBA to create a macro that toggles highlighting on and off, depending on the current state of the selected rows.
It may seem intimidating at first, but it’s like learning to tweak a recipe. Once you understand the basics, you’ll wonder how you ever managed without it. And the best part? You don’t need to be a coding expert to get started.
Upgrading Macros to Work on Multiple Rows (with VBA)
The macros you recorded only work on single rows. To make them work on multiple rows, we need to tweak the VBA code:
Combining Macros into a Toggle (with VBA)
Now let’s combine both macros into one that toggles the highlighting on and off.
[VBA Code Box]
Sub Highlight_Toggle()
If ActiveCell.Font.Bold = False Then
' Highlight On
Selection.EntireRow.Select
Selection.Font.Bold = True
Selection.Font.Italic = True
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else
' Highlight Off
Selection.EntireRow.Select
Selection.Font.Bold = False
Selection.Font.Italic = False
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
End Sub
Adding Buttons for Ease of Use
Now you can click the button to toggle highlights on and off.
Note: This is not a true "toggle". It doesn't look through every row and change the highlighting on when it's off and off when it's on. It just looks at the active cell and if it's not bold then it turns the highlighting on for all rows, and if the active cell is bold then it turns the highlighting off for all rows.
If we want to make it a true "toggle" we could use a "For Each" to check each row in the selection and make sure that if it's not yet highlighted to turn on the highlighting and if it's already highlighted to turn it off. I teach all of this and more in my online course.
Automate Filtering with Macros
Filtering data in Excel is a common task, and macros can make it lightning fast. For instance, you might often need to focus on specific rows, such as:
To automate these tasks:
Once recorded, assign these macros to buttons, giving you one-click access to filter exactly what you need. Make sure the names of your buttons match the macro tasks for clarity.
Automate Sorting with Macros
Sorting data is another task where macros can save time. Suppose you want to sort a "Certainty" column in ascending or descending order. Here’s how to automate it:
By assigning these macros to buttons, you can sort data instantly with just one click, saving time and effort. Clearly label your buttons to match the sorting tasks for ease of use.
In 2011, I was working under intense pressure with a high-stakes deadline. The company’s board of directors needed updated reports for an important meeting, and I had just minutes to deliver them.
My hands were cold and clammy as I held a stack of papers like a shield outside the VP’s office. Inside, the VP—my boss’s boss—was reviewing the first version of the reports with a red pen, ready to mark up any mistakes.
Suddenly, his computer dinged with an email: there was a last-minute change that had to be reflected in the reports.
I scrambled back to my desk. There were only 30 minutes left before the meeting. I opened Excel, clicked a few buttons to run my macros, and watched as they flawlessly updated the reports in minutes.
Without VBA, this task would have taken hours, and I would have missed the deadline.
Instead, the reports were ready with 20 minutes to spare. The VP commended my quick turnaround, and I realized in that moment how much VBA had saved my job and transformed my career.
How a Chance Encounter Got me into Excel VBA
Another pivotal moment came years earlier, back when I was working at a billion-dollar tech company.
I was in the open floor office, staring at a colleague’s laptop screen during a meeting. She opened an Excel file and then clicked a button that brought up the VBA editor.
At first glance, the editor looked overwhelming, filled with a ton of code that seemed completely foreign to me.
But then she began explaining what it all meant. The macros she had written were automating hours of repetitive work, saving her time every single week.
She showed me how it helped her prepare reports by handling data preparation, formatting, and analysis with just a few clicks. These reports were critical and went straight to the company’s senior executives, including the CEO and CFO.
Her words struck me deeply: “This is the only way I can meet my Monday afternoon deadline. Without these macros, I’d never finish in time.”
And then she added, “By the way, these reports are about to become your responsibility. You’ll need to learn VBA fast if you want to succeed in this role.”
That moment was a turning point.
Suddenly, VBA didn’t look so intimidating. It looked like a powerful cheat code that could make my life easier and let me meet those critical deadlines.
From then on, I made it my mission to learn VBA, and it transformed not only how I worked but how I viewed Excel as a tool for solving problems.
Learn VBA the Right Way
The truth is that most Excel users have no idea that VBA even exists, or they see it as something that's just too hard to learn.
But I'm here to help you take that next step and learn VBA for yourself. I spent years figuring out how to teach VBA so there's nothing to stop you.
More than 500 Excel users have taken my Excel VBA course, and now they use VBA to automate their work. And that could be you in a few weeks' time.
How my VBA Course is Designed
My course has over 10 hours of video tutorials taking you from the basics of macros to doing some advanced tasks with VBA. It also includes practice files and quizzes to keep the concepts fresh and give you the much needed practice to get good at Macros and VBA.
The course is split into three levels:
In Level 1 just like teaching someone to drive a car, I start with the basics of car control and road awareness. This means recording macros and learning how to use the VBA editor to write and edit code.
In Level 2 we take the car out onto public roads. Just like a learner driver practices to handle road signs and traffic, in Excel, I show you important ways to handle macros and VBA.
And in Level 3 we jump into the fast lane and turbocharge what you learned in earlier levels. You start to make reports fly out and then automate your work based on the foundations you learned in Levels 1 and 2.
Check out my VBA Course
When you can write VBA code efficiently and confidently it will change the trajectory of your career or business.
So, if you're ready to transform the way you work in Excel and automate repetitive tasks, check out the link to my online course. And I hope to see you inside soon!
Hi, I'm Victor!
Are you struggling with complex Excel tasks? Feeling overwhelmed by spreadsheets that are hard to use?
Many people believe mastering Excel is about learning shortcuts, functions, and formulas. But this overlooks the importance of building practical, real-world applications. It's not just about knowing the tools. It's about using them effectively.
That's where I come in. You'll get a unique perspective to Excel training from me. I have over 20 years of experience at Deloitte and two global tech companies. And I know what can make a difference in your career.
Let me help you integrate Excel into your professional life. Starting today. Read one of my articles, watch one of my videos. Then apply the new technique to your work. You'll see the difference immediately!
Discover the PROVEN Blueprint for transforming your Excel skills, supercharging your productivity, and standing out in your career! My course helps you to learn Excel VBA and save hours of time even if you have zero prior experience with programming.
Solve tricky Excel problems and take your work to the next level! Get customized solutions for your unique needs. Save time and gain insights with truly expert Excel solutions from only $97 per task.
Get a clear overview of your project progress using the Excel project timeline. Use it to communicate the big picture, track task progress, and stay on top of your project goals. Stay organized with our project timeline!
Our cheat sheets provide quick and easy reference to commonly used Excel VBA concepts and code snippets.
Unlock new levels of productivity and efficiency with our cheat sheets, and write VBA code like a pro in no time.
RECOMMENDED READING
Are you looking to upskill and stay ahead of the curve? Excel is a powerful tool that keeps growing in demand. We round up the best online courses for learning Excel.
Are you looking to up your spreadsheet game? Excel is an invaluable tool that can help you stay organized and save time. From data analysis to budgets, Excel can do it all!
Today, having Excel skills is more critical than ever. Those who know how to use Excel are more likely to find higher-paying jobs. And get promoted faster.