A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
I tried your code exactly, it was processing for a very long time, much longer than I had expected, so I force-closed excel and started over
Hello Michael,
If you had to force close Excel then I believe that something else is wrong. Even with a vast number of worksheets I should think that it will run in the blink of an eye. However, please tell how many worksheets you have and I will create a workbook with that number of sheets and tell you how long it takes to run.
The following code will test for worksheets without headers and skip them but the code should not really require the test because the Replace function simply ignores the zero length string. I have even tested the code after setting bold print for some worksheets and it still works.
Sub ReplaceHeaders()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.PageSetup.CenterHeader <> "" Then
ws.PageSetup.CenterHeader = Replace(ws.PageSetup.CenterHeader, "Q3 2013", "Q4 2013")
End If
Next ws
End Sub
Your posted code for ActiveSheet is missing ActiveSheet before PageSetup. Should be like the following.
ActiveSheet.PageSetup.CenterHeader = Replace(ActiveSheet.PageSetup.CenterHeader, "Q3 2013", "Q4 2013")