If you haven’t used macros before, the Developer tab might be hidden. Right-click any ribbon tab > Customize Ribbon > Check the "Developer" box > OK.

Step 2: Record Your Macro
We’re going to record a macro that transforms the table on the left below, to the nicely formatted table with the column
order rearranged and the data sorted by category and product.

- On the Developer tab, click Record Macro.
- Name it FormatData (macro names can't have spaces and must start with a letter).
- Choose to store it in your Personal Macro Workbook so it’s available across all workbooks.
- Click OK - Excel is now recording.

Step 3: Perform Your Actions
To format this daily sales report:
- Remove bold and borders from headers (Home > Clear > Formats)
- Apply a blue fill and white bold font to headers
- Format the Sales column with comma separators
- Move the Category column to the front
- Sort by Category and then Product
When done, click Stop Recording in on the Developer
tab:

Step 4: Run Your Macro
Open another unformatted copy of the data. Go to the Developer tab > Macros (or Alt + F8), select FormatData, and click Run.

All formatting is applied instantly.
That’s the magic of macros - automating repetitive work.
Note: VBA changes can't be undone - they are permanent.
Peek Under the Hood with the VBA Editor
Macros don’t just automate clicks - they write VBA code behind the scenes.
Go to Developer > Visual Basic (or press Alt + F11) to open the VBA Editor.
In the Project pane, locate PERSONAL.XLSB and double-click the module containing your macro. You’ll see code like this:

Even if you don’t understand it all yet, this is where you gain control and flexibility.
Writing Your Own VBA Procedure
A procedure is a named block of code that performs a task. There are 3 types:
- Sub Procedures - perform actions
- Function Procedures - return
results
- Property Procedures - used in advanced scenarios
For simplicity, we'll stick with a Sub.
Step 1: Insert a Module
In the VBA Editor, right-click your workbook > Insert > Module.

This opens a new coding pane on the right for the module:

Step 2: Create a
Procedure
Here we can write the code for our procedure to formats header cells with bold text and a light purple background: