Code for formatting header

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
 
F

Frank Kabel

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
 
B

Bob Phillips

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)
 
D

Dave Peterson

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!
 
M

Matthew McManus

Thanks Bob for the tip and the warning - I did get a shock the first
time I entered the header starting with 2004. :)

Matthew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top