Syntax problem in Page Header build

LostInVBA

New Member
Joined
Apr 6, 2011
Messages
3
I am using XP-PRO and Office 2010. I am having problems with the syntax when building the header for printing. I currently have the following code,

With ActiveSheet.PageSetup
.LeftHeader = "Data as of:" & Chr(10) & vGenDate
.CenterHeader = _
" &B&""Comic Sans MS""&14Supposed to be line 1 &B&""Ariel""&10 Suppose to be line 2 Suppose to be line 3 with " & vGenLoc
End With

The LeftHeader prints fine on two lines, but the CenterHeader is currently printing with the correct fonts, size, and bold characteristics, but as one continuous line because I cannot get the system to recognize my carriage return /line feed. ( chr(10) )
How should they be included?

Ideally someone will come up with this code;

With ActiveSheet.PageSetup
.CenterHeader = _
vLine01 _
vLine02 _
vLine03
End with

where all the print characteristics (Font, Size, Bold, NewLine, etc) are built into the Line variables.

THANKS!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Thank you for the info, but color me clueless.

It looks like VBCR is what I'm looking to do, but...

I cannot get the syntax for the CenterHeading correct :(

I have tried surrounding it with quotes ("), ampersands (&), blanks( ), and not surrounding it with anything.

Everything I try gives me the dreaded, "Compile Error. Expected: End of statement" message box.
 
Upvote 0
It ain't pretty, but this seems to be what you want

Code:
    With ActiveSheet.PageSetup
        .CenterHeader = _
            "&""Comic Sans MS,Regular""&14" & "line 1 text" & vbcr & _
            "&""Arial,Regular""&10" & "line 2 text"
    End With

chr(10) and vbcr have the same effect here, but I just prefer using vbcr(VB Carriage Return) because it is easier to recall what it is...
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,183
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top