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.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,214,606
Messages
6,120,478
Members
448,967
Latest member
visheshkotha

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
Back
Top