Visual basic code with macros

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

Guest

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.
 
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.
 

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