Header / Footer code

Dr. Demento

Well-known Member
Joined
Nov 2, 2010
Messages
618
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I have the following code and it works appropriately. However, I have decided to have a global constant where I can pick my font and make it be uniform everywhere and if I want to change it, I only have to change a single variable. My questions is: how do I adapt this code such that instead of Calibri in the header, it references the global string constant 'font_univ'??

VBA Code:
.CenterHeader = strFont & "File:  &F  ||  Sheet: &""[Calibri],Bold""&KDB2929&A&""[Calibri],Regular""&K01+000"

The variable strFont = "&""[" & font_univ & "]""&10" and it occurs to me that I can eliminate the [Calibri] reference in the CenterHeader completely! Still, don't know how to do that either :rolleyes: And, I'm not sure I set up strFont appropriately either; it was originally:

VBA Code:
strFont = "&""["Calibri"]""&10"

I need all sorts of help. Thanks y'all.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Declare strFont like this.
VBA Code:
strFont = "Calibri"
Use it like this.
VBA Code:
.CenterHeader = strFont & "File:  &F  ||  Sheet: &""[" & strFonr &"],Bold""&KDB2929&A&""[" & strFont & "],Regular""&K01+000"
 
Upvote 0
Thanks, Norie but that doesn't seem to work. When I look in Page Setup, the font is listed as "[Calibri]" (with brackets) and is the default font, not what I want.

Also, if the first statement of the CenterHeader details the font, can I and how would I eliminate it from the remainder of the line?

Thank much, kind sir.
 
Upvote 0
When I look in Page Setup I also see Calibri highlighted, but when I change the font with the code to, say, Arial and print CenterHeader to the Debug window I see Arial.
VBA Code:
strFont = "Arial"
Sheet1.PageSetup.CenterHeader = "File:  &F  ||  Sheet: &""[" & strFont & "],Bold""&KDB2929&A&""[" & strFont & "],Regular""&K01+000"
Debug.Print Sheet1.PageSetup.CenterHeader
 
Upvote 0
I think I was trying to over-complicate it. Thanks, Norie!

I want to be puffin when I grow up!!
 
Upvote 0

Forum statistics

Threads
1,214,589
Messages
6,120,415
Members
448,960
Latest member
AKSMITH

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