Changing Font Type in Header VBA Code

RobR1981

New Member
Joined
Sep 11, 2019
Messages
3
Hello Everyone,

I'm getting some odd behavior when I try running some VBA code that updates the font type in a page header. Here is the snippet of code:

Code:
With masterWkbk.Worksheets("Dashboard")
     .PageSetup.RightHeader = "&""Times New Roman,Regular" & Format(Now, "YYYY") & " " & prevQtr & qtrEndingDate
End With
Running the macro places September 30, 2019 in the header.

If I remove the "&""Times New Roman,Regular" portion, I get the correct result:

2019 3rd Quarter / Ending September 30, 2019

Can't figure out what I am doing wrong.

The prevQtr and qtrEndingDate are of course variables and defined above that line of code.
 

John_w

MrExcel MVP
Joined
Oct 15, 2007
Messages
5,954
Try this:
Code:
        .PageSetup.RightHeader = "&""Times New Roman,Regular"" " & Format(Now, "YYYY") & " " & prevQtr & qtrEndingDate
If you want an explicit font size (e.g. 8):
Code:
        .PageSetup.RightHeader = "&""Times New Roman,Regular""&8 " & Format(Now, "YYYY") & " " & prevQtr & qtrEndingDate
 

Forum statistics

Threads
1,078,358
Messages
5,339,738
Members
399,320
Latest member
zim1984

Some videos you may like

This Week's Hot Topics

Top