Change font in header

sandyaggie

New Member
Joined
Aug 25, 2006
Messages
12
I want to change the font in the page header, but can't figure out how to do it in VB. This macro formats data exported from another program. That program populates the header, which is fine, but I just want to change the font.

Can I somehow pick up the current text in the header into a variable?

Any other ideas?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Example

Code:
ActiveSheet.PageSetup.CenterFooter = "&""Times New Roman,Regular""&14" & Sheets("Employees").Cells(i, 1).Value
 
Upvote 0
Thanks for that fast reply.

If I'm not mistaken, your code sets the text header to be whatever is in the worksheet called "Employees".

I want my code to leave the text of what is already in the header and change the font. Here's my example:

ActiveSheet.PageSetup.RightHeader = "&""Tempus Sans ITC,Bold""&12 & [Company Name text goes here]
 
Upvote 0
Maybe like this (untested)

Code:
With ActiveSheet.PageSetup
    s = .RightHeader.Text
    .RightHeader = "&""Tempus Sans ITC,Bold""&12 & s"
End With
 
Upvote 0
Drat. Tried that and it came back with a 424 error- Object Required.

Any other ideas?

So close and yet so far!
 
Upvote 0
Tried that, but then it ends up picking up the formatting info as well. That is, the variable's value becomes ""&""Times New Roman,Regular""&14 & [Company Name text]"". Unfortunately, it doesn't extract the text from the header.

I also tried .value and got the same Object Required error.
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,462
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