Code for formatting header

  • Thread starter Thread starter Matthew McManus
  • Start date Start date
M

Matthew McManus

Hi all,
I am hoping that this is a trivial problem. I wish to format a header'
fonts after a user enters the text in a Input Box.

At the moment I have:

stranswer = InputBox("Enter heading")
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = stranswer
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.....

How do I tell it to format the header with, for instance, Times Ne
Roman bold 20 point?

Sincere thanks for any help

Matthe
 
Hi
you can use format codes for this (look in the VBA help file for more
about this). To give you an example
LeftHeader = "&""Arial""&B&20Test Header"

the easiest way to get these codes would be to record a macro while
change the page setup
 
Hi Matthew,

With ActiveSheet.PageSetup
.CenterHeader = "&""Times New Roman,Regular""&20" & stranswer
End With

Now wasn't that obvious<vbg>?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Just a small warning that may not matter:

If that first character of stranswer is a number, then the font size may be a
little larger than you want. I'd add a space character:

..CenterHeader = "&""Times New Roman,Regular""&20 " & stranswer

===
if stranswer were "8th Place finish", then the fontsize would be close to 208!
 
Thanks Bob for the tip and the warning - I did get a shock the first
time I entered the header starting with 2004. :)

Matthew
 
Back
Top