VBA & Macro Problems

How to Use VBA to Add Different Footers to Multiple Excel Workbooks

Anum MushtaqAnum Mushtaq Nov 2, 2026 869 views

Question details

The user needs to automate the process of applying distinct footers to multiple Excel workbooks by reading corresponding footer values from a master workbook.

How to Use VBA to Add Different Footers to Multiple Excel Workbooks
Product
Excel
Device & OS
not provided
Scenario
Batch-updating center footers for numerous Excel files stored in a folder based on a specific list of values (e.g., cells C1:C10) in a master workbook.
Observed behavior
Requires a script that opens each workbook, reads the correct footer value from the master sheet, updates the target workbook's center footer, saves, and closes the file automatically.
Before you start

Ensure all target Excel files are stored in an accessible folder and back up your workbooks before running the macro, as VBA changes cannot be easily undone.

Solution 1Recommended

Create a VBA Macro to Loop Through and Update Workbooks

Record a basic macro for setting a footer, then modify it with a loop to dynamically read filenames and footer values from your master workbook.

Instead of applying a hard-coded footer manually, you can use a loop in VBA. The script will iterate through your master list, open each target file, apply the specific center footer, save the changes, and close the file automatically.

1
Set Up the Master Workbook

Create a master workbook where one column contains the full file paths of the target workbooks and another column (e.g., C1:C10) contains the corresponding footer values.

2
Record a Base Macro

Go to the Developer tab, click 'Record Macro', open one of the target files, set the center footer via the Page Setup menu, save, close the file, and stop recording.

3
Open the VBA Editor

Press Alt + F11 to open the Visual Basic for Applications (VBA) editor and locate the module containing your recorded macro.

4
Modify the Code with a Loop

Wrap your recorded code in a 'For' or 'Do While' loop. Replace the hard-coded file path and footer text with variables referencing your master sheet's cells. Ensure you include 'Workbooks.Open' at the start of the loop and 'ActiveWorkbook.Close SaveChanges:=True' at the end.

5
Run the Macro

Press F5 or click 'Run' within the VBA editor to execute the script and automatically update the footers in all listed workbooks.

Create a VBA Macro to Loop Through and Update Workbooks
VBA Execution Speed: Add 'Application.ScreenUpdating = False' at the beginning of your code and set it to 'True' at the end to prevent screen flickering and significantly speed up the batch process.
Efficient Spreadsheet Automation

Automate Footers in Multiple Workbooks with WPS Spreadsheet

WPS Office provides robust support for VBA macros, allowing you to seamlessly automate repetitive tasks like batch updating footers across multiple Excel files. Enjoy a lightweight and highly compatible spreadsheet environment.

  1. 1. Enable Developer Tools: Open WPS Spreadsheet, go to the Options menu, and ensure the Developer tab is enabled so you can access Macro features.
  2. 2. Launch the VBA Editor: Click on the Developer tab on the ribbon and select 'Visual Basic Editor', or simply press Alt + F11.
  3. 3. Insert the Automation Script: Insert a new Module from the Insert menu and paste your looping VBA script designed to read the master workbook and update the footers.
  4. 4. Execute the Macro: Click the Run button or press F5 to execute the macro and automatically batch-process the footers for all your listed workbooks.
Fully compatible with Microsoft Excel (.xlsx, .xlsm) formats and macro scripts.Built-in VBA editor to write, debug, and execute macros effortlessly.Supports advanced Page Setup and footer customization via code.Free to download with a familiar, easy-to-use tabbed interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my VBA macro applying the identical footer to all workbooks?

This occurs if your footer text is hard-coded into the macro. Ensure you replace the specific footer string with a dynamic variable that points to the changing cell values (like cells C1:C10) in your master workbook during each loop iteration.

Do I need to keep the target workbooks open while the macro runs?

No. A properly written VBA script includes commands to automatically open the target workbook using 'Workbooks.Open', apply the footer, save the changes, and close it using 'ActiveWorkbook.Close SaveChanges:=True' before moving to the next file.

Can I apply different font formatting to the center footer using VBA?

Yes, you can include formatting codes in your VBA footer string. For example, prepending '&"Arial,Bold"' to the footer variable string will apply bold formatting to the CenterFooter property.