not looping through open workbooks properly

klarowe

Active Member
Joined
Mar 28, 2011
Messages
389
I have this code:
Code:
Sub StandardFooters()
    Dim wb As Workbook
    Dim ws As Worksheet
 
    For Each wb In Workbooks
        Set ws = ActiveWorkbook.Worksheets("Home")
            ws.PageSetup.CenterFooter = Format(ws.Range("A49").Value)
    Next wb
End Sub

that is supposed to loop through the open workbooks and if I step through it, it goes back through for each open workbook... but then if I go into the workbooks, it only did it for the "activated" workbook and none of the others???? But then sometimes it will do it for 2 of them and no more??? I'm completely lost.

Edit: Nevermind, posting the code actually helped me notice what I did. I put activeworkbook.worksheets("Home") instead of wb.worksheets("Home")
Mods, please feel free to delete.
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Watch MrExcel Video

Forum statistics

Threads
1,122,694
Messages
5,597,571
Members
414,156
Latest member
WDMix

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top