Programatically changing font size in custom header

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to set a custom header with the filename and sheetname - easy enough,
I can do that with...

ActiveSheet.PageSetup .LeftHeader = "&F &A"

....but that appends .xls onto the filename, which I don't want.

Elsewhere in the workbook I have to work out the filename minus the .xls, so
I figured I'd use the value from this procedure (fname - string variable) in
the custom header dialog

ActiveSheet.PageSetup .LeftHeader = fname & " " & "&A"

That works ok, but I want the text to be 18pt. I recorded a macro to work
out how to change the font size in the custom header and it's done by
prefacing the &A with &18. Problem is, I can't put &18 in front of the
variable fname....

None of the following return the right result:

ActiveSheet.PageSetup .LeftHeader = "&18"fname & " " & "&18&A" (--expects
end of the procedure)
ActiveSheet.PageSetup .LeftHeader ="&18 fname" & " " & "&18&A" (--types
fname instead of the actual value of the variable)

Can somebody help me with this please? Am I going about it in totally the
wrong way? Any and all suggestions greatly appreciated :)
 
Sub AAA()
fName = "House"
ActiveSheet.PageSetup.LeftHeader = _
"&18" & fName & " " & "&A"
End Sub

worked for me. Spacing is important.
 
D'oh.

Thank you Tom, I was being a moron :)


Tom Ogilvy said:
Sub AAA()
fName = "House"
ActiveSheet.PageSetup.LeftHeader = _
"&18" & fName & " " & "&A"
End Sub

worked for me. Spacing is important.
 

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

Back
Top