ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   set header font size using a variable? (https://www.excelbanter.com/excel-programming/338866-set-header-font-size-using-variable.html)

Seth

set header font size using a variable?
 
I am trying to set the header font size to a variable (I just am using a
constant in this example), but am having no luck getting it to print. I have
tried many attempts but am not getting what I need. So far I get no header
or some other formatting (time, strikethrough, etc). Please help. Thanks in
advance.

FS = 36

..CenterHeader = "&""Times New Roman,Bold" & FS & "ATTACHMENT I"
does not work

..CenterHeader = "&""Times New Roman,Bold""&FSATTACHMENT I"
does not work either

Tom Ogilvy

set header font size using a variable?
 
If you record a macro you get:

..CenterHeader = "&""Times New Roman,Regular""&36ATTACHMENT I"

so to replace the 36 you need

..CenterHeader = "&""Times New Roman,Regular""&" & FS & "ATTACHMENT I"

the first ampersand after ",Regular" is part of the string, the second is
the concatenation operator

--
Regards,
Tom Ogilvy


"Seth" wrote in message
...
I am trying to set the header font size to a variable (I just am using a
constant in this example), but am having no luck getting it to print. I

have
tried many attempts but am not getting what I need. So far I get no

header
or some other formatting (time, strikethrough, etc). Please help. Thanks

in
advance.

FS = 36

.CenterHeader = "&""Times New Roman,Bold" & FS & "ATTACHMENT I"
does not work

.CenterHeader = "&""Times New Roman,Bold""&FSATTACHMENT I"
does not work either




kraljb[_14_]

set header font size using a variable?
 

Because it is treating the &'s as part of the string...

You should change it like so...
CenterHeader = "&" & chr(34) & "Times New Roman,Bold&"&chr(34)&" & FS &
"&ATTACHMENT I"

(The Chr(34) returns the double quote to make it easier to read


--
kraljb
------------------------------------------------------------------------
kraljb's Profile: http://www.excelforum.com/member.php...fo&userid=9955
View this thread: http://www.excelforum.com/showthread...hreadid=400911


Seth

set header font size using a variable?
 
Great! It works now as intended. Thanks a bunch!

"Tom Ogilvy" wrote:

If you record a macro you get:

..CenterHeader = "&""Times New Roman,Regular""&36ATTACHMENT I"

so to replace the 36 you need

..CenterHeader = "&""Times New Roman,Regular""&" & FS & "ATTACHMENT I"

the first ampersand after ",Regular" is part of the string, the second is
the concatenation operator

--
Regards,
Tom Ogilvy


"Seth" wrote in message
...
I am trying to set the header font size to a variable (I just am using a
constant in this example), but am having no luck getting it to print. I

have
tried many attempts but am not getting what I need. So far I get no

header
or some other formatting (time, strikethrough, etc). Please help. Thanks

in
advance.

FS = 36

.CenterHeader = "&""Times New Roman,Bold" & FS & "ATTACHMENT I"
does not work

.CenterHeader = "&""Times New Roman,Bold""&FSATTACHMENT I"
does not work either






All times are GMT +1. The time now is 11:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com