I want to turn my right header text grey! Seems so simple but nothing is working sorry in advanced!! How my worksheet is set up is it looks like regular print paper, and has 3 header sections: left middle and right Below is the code for what text goes in the right header. If important please note there is a constant title in the middle header. Right header will be variable that changes with each execution of the code
Dim wo As String
wo = ws.Cells(lastRow + 1, c).Value
ws4.PageSetup.RightHeader = wo
I was about to mark the question as duplicate, however, exactly for defining the font color, the answer given for Formatting the texts using PageSetup.CenterHeader is not correct (it misses the "K")
Basically, you format text for the header or footer pieces by adding special formatting codes into the text. Those codes starts with an ampersand character. For example, bold characters is &B
, setting the font to 14px is &14
. Setting the font color is &K
, followed by the hex value of the color. Red is &KFF0000
(FF for Red, 0 for Green and Blue). Gray would be for example &KA0A0A0
(=A0 for Red, Green and Blue).
A large bold text in red is marked with &B14&KFF0000
. Simply add this formatting code as prefix to your header text, e.g. "&B14&KFF0000" & wo
As you want gray text, write
Dim wo As String
wo = ws.Cells(lastRow + 1, c).Value
ws4.PageSetup.RightHeader = "&KA0A0A0" & wo
If I were you, I would define a constant:
Const GrayText = "&KA0A0A0"
Dim wo As String
wo = ws.Cells(lastRow + 1, c).Value
ws4.PageSetup.RightHeader = GrayText & wo