You could use this code:
Sub CellInHeader()
Dim ws As Worksheet
Dim hdr As String
Dim arrSheets
Dim myPath As String
Dim objFso As Object
Dim myFolder As Object, myFile As Object
Dim wb As Workbook, i As Integer
Set objFso = CreateObject("Scripting.FileSystemObject")
'set the array of sheets to be worked on
'list the sheet names here
arrSheets = Array("Sheet1", "Sheet2", "Sheet3")
'folder with files to update
myPath = "C:\..." 'Insert here your path
'turn off screen updating to speed up the macro
Application.ScreenUpdating = False
Set myFolder = objFso.GetFolder(myPath).Files
For Each myFile In myFolder
Set wb = Workbooks.Open(myFile)
For i = LBound(arrSheets) To UBound(arrSheets)
Set ws = wb.Sheets(arrSheets(i))
hdr = ws.PageSetup.CenterHeader
hdr = Left(hdr, InStr(hdr, Chr(10)))
ws.PageSetup.CenterHeader = hdr & "Annual Report " '& CHANGES HERE! ActiveWorkbook.Sheets("Sheet4").Range("=A20").Text
Next i
wb.Close SaveChanges:=True
Next
Application.ScreenUpdating = True
End Sub
Regards,
Antonio
Bookmarks