TAPS_MikeDion
Well-known Member
- Joined
- Aug 14, 2009
- Messages
- 622
- Office Version
- 2011
- Platform
- MacOS
Hi everybody,
I have code to add the year to the header, but I need it to run through all sheets and it only works for the active sheet. Also, I wanted to have it use Arial, bold and font size 18. I've tried many different things that I thought might work, but they don't. I made the lines that aren't working into comments just to hang on to them for now. Please see below. Any help is greatly appreciated, thank you!
I have code to add the year to the header, but I need it to run through all sheets and it only works for the active sheet. Also, I wanted to have it use Arial, bold and font size 18. I've tried many different things that I thought might work, but they don't. I made the lines that aren't working into comments just to hang on to them for now. Please see below. Any help is greatly appreciated, thank you!
VBA Code:
Sub header_year()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Sheets
With ws
With ActiveSheet.PageSetup
'.CenterHeader.Font.Name = "Arial"
'.CenterHeader.Font.Size = 18
'.CenterHeader.Font.Bold = True
.CenterHeader = Chr(10) & Format(Date, "yyyy") & " TRAFFIC DIVISION"
End With
End With
Next ws
End Sub