This repository contains a simple Excel VBA automation tool that applies consistent header formatting across all sheets in a workbook. The project demonstrates how to use a VBA loop to automate repetitive formatting tasks.
CleanUpData.xlsm
β Macro-enabled Excel file containing the VBA scriptRawData.xlsx
β Sample raw data used for testingSample.png
β Example output showing formatted headers
- Automates header formatting for all worksheets in an Excel workbook
- Combines macro recording and manual VBA scripting
- Easy to use and modify for similar automation tasks
-
First, the macro recorder is used to capture the steps for:
- Adding headers
- Formatting headers
-
The recorded process is wrapped into a loop using Visual Basic for Applications (VBA), so the formatting can be applied to every worksheet.
Public Sub CleanUpData()
Dim i As Integer
i = 1
Do While i <= Worksheets.Count
Worksheets(i).Select
AddHeaders
FormatHeaders
i = i + 1
Loop
End Sub
Note:
AddHeaders
andFormatHeaders
should be defined as separate subroutines in your VBA module.
- Open the
CleanUpData.xlsm
file in Excel. - Navigate to the Developer tab.
- Click on Visual Basic β open
Module 1
to view the code. - Or go to Developer β Macros β run the
CleanUpData
macro to apply the formatting. - See
Sample.png
for a visual example of the expected output.
- LinkedIn: Max Nguyen Hoang Minh
- Email: maxnguyenhoangminh@gmail.com