Skip to content

Minh-milk-bottle/VBA-loop-formatting-headers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VBA-loop-formatting-headers

Excel VBA Automation: Header Formatting Loop

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.

πŸ“‚ Files in This Repository

  • CleanUpData.xlsm – Macro-enabled Excel file containing the VBA script
  • RawData.xlsx – Sample raw data used for testing
  • Sample.png – Example output showing formatted headers

βš™οΈ Features

  • 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

πŸ” How It Works

  1. First, the macro recorder is used to capture the steps for:

    • Adding headers
    • Formatting headers
  2. The recorded process is wrapped into a loop using Visual Basic for Applications (VBA), so the formatting can be applied to every worksheet.

🧠 VBA Code Sample

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 and FormatHeaders should be defined as separate subroutines in your VBA module.

πŸš€ How to Use

  1. Open the CleanUpData.xlsm file in Excel.
  2. Navigate to the Developer tab.
  3. Click on Visual Basic β†’ open Module 1 to view the code.
  4. Or go to Developer β†’ Macros β†’ run the CleanUpData macro to apply the formatting.
  5. See Sample.png for a visual example of the expected output.

πŸ“§ Contact


About

Excel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published