VBA to set colour of header or footer text?

Phil Smith

Active Member
Joined
Aug 13, 2004
Messages
285
Office Version
  1. 365
Platform
  1. Mobile
Is it possible to use VBA to change the colour of text in the header or footer of an Excel worksheet, and if so, what is the correct syntax?

I have looked around on the internet and come up with &Kcolour, where colour is a hexadecimal value, then converted my RGB values to hexadecimal, but my text is stubbornly staying at black.

Any takers?

Phil
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Got it!

After some more head scratching I found out that the &Kcolour needs to go after any other formatting and IMMEDIATELY before the text that is to have it's colour changed.

I ended up with:

Rich (BB code):
.CenterHeader = "&C&50&""Arial""&K00007DText to be formatted"

which turns my text into a darkish shade of blue.

I was originally trying with:

Rich (BB code):
.CenterHeader = "&K00007D&c&50&""Arial""Text to be formatted"

whcih did NOT work.

So problem solved!
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,480
Members
452,915
Latest member
hannnahheileen

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