Visual basic code with macros

D

dmt

I want to put a named variable into a Header or footer and be able to format the variable to get larger font. I can get the variable into the footer through macro code but not add the formatting code. Is this possible? Can anyone help?
Thanks.
 
D

Dave Peterson

I recorded a macro when I did it manually.

This was the bit I kept:

With ActiveSheet.PageSetup
.CenterFooter = "&20asdfasdf"
End With

I could modify that to look like:

Dim myStr As String

myStr = "This is a test!"
With ActiveSheet.PageSetup
.CenterFooter = "&20" & myStr
End With

And if your variable starts with a number, I'd do:

Dim myStr As String

myStr = "This is a test!"
With ActiveSheet.PageSetup
.CenterFooter = "&20 " & myStr
End With

(extra space after &20.)

Just to make sure that excel sees the size as 20 and not a size concatenated
with your string.
 
Top