VBA - formatting header/footer font colour

ChloeLM

New Member
Joined
Apr 12, 2021
Messages
5
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
  2. Mobile
  3. Web
Hi everyone

I'm formatting a header/footer on my sheet. I've worked out how to change the font, size and whether it's bold. I'm struggling to change the font colour/tint though, it's not clear where the instructions go. I'm also not certain about what the code for this looks like, according to the help guide it's &K xx. S nnn but that gives me alot to go wrong!!

Based on the theme colour elsewhere I've used:
VBA Code:
ThemeColor = xlThemeColorLight1 
.TintAndShade = 0

I'm trying to add the code to change the colour to the following three lines:
Code:
FirstPage.RightFooter.Text = "&08&""DM Sans""Page &P of &N"
.FirstPage.CenterFooter.Text = "&10&""DM Sans""Confidential"
.FirstPage.LeftFooter.Text = "&""DM Sans""&08" & Range("A2")


Please can anyone help me to understand what the instruction to change the colour looks like, and where it goes?

Any assistance gratefully received!
Thanks
Chloe
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
VBA Code:
With ActiveSheet.PageSetup
    .CenterFooter = "&KFFFF00" & "This is yellow text footer"
    .RightFooter = "&KFF0000" & "&08&""DM Sans""Page &P of &N I AM RED"
    .LeftHeader = "&K00FF00" & "&08&""DM Sans""I AM GREEN HEADER"
End With
Long story short: &K and hex coded colour.
 
Upvote 0
Solution
VBA Code:
With ActiveSheet.PageSetup
    .CenterFooter = "&KFFFF00" & "This is yellow text footer"
    .RightFooter = "&KFF0000" & "&08&""DM Sans""Page &P of &N I AM RED"
    .LeftHeader = "&K00FF00" & "&08&""DM Sans""I AM GREEN HEADER"
End With
Long story short: &K and hex coded colour.
Bingo! Thanks :)
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,090
Latest member
vivek chauhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top