Create a Page Header using a Macro.. NOT working.

mateo

New Member
Joined
Aug 18, 2009
Messages
5
I have a employee who wants to create an Excel page header using a macro (shown below... CenterHeader in BOLD). I am by no means a macro master but the ticket eventually got to me and since I am stuck I am posting it here.

With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""&14 My Company Name&""Arial,Regular""&10" & Chr(10) & "&""Arial,Bold""&12 Agriculture Shop Operations Summary&""Arial,Regular""&10" & Chr(10) & "&12For the week ending January 15, 2012" & Chr(10) & ""
.LeftHeader = ""
yada yada yada....
End with

When you run the macro it all looks good except the CenterHeader part ends at For the week ending, it doesn't show the January 15, 2012? Run it again and your results are a bit different, still with most of it working but the final row being cut off like For the week end

I read about a character limitation for .CenterHeader but I did a check and think we are in bounds. My user and the first level support said that if you step through the macro in the editor it works, but not when you run it (I just realized I did NOT confirm that claim, but do believe them).

I asked about why he would hardcode the date in the macro instead of using a variable but that is what they want to do.

I tried shortening the string, removing the font sizes, mixed and matched and after awhile had to move on to other things and gave up.

Everyone testing this issues is running Office 2010 on a Windows 7 machine and the issue has been reproduced on all 3 machines.

I can enter data in a single, merged cell, and make that a Header by referencing that cell in the macro, but then all the fonts and font sizes are the same.

What am I missing? Any other alternative suggestions?

thanks in advance.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Works for me. I get:

My Company Name
Agriculture Shop Operations Summary
For the week ending January 15, 2012

with the appropriate formatting.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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