Help with Headers

Dan Wilson

Well-known Member
Joined
Feb 5, 2006
Messages
546
Office Version
  1. 365
Platform
  1. Windows
Good day. I am running Office 365 on Windows 10 Home. I have a workbook with seven worksheets, each having a Header. I have several Macros, each one producing a different version of the data on a worksheet. In each Macro there is the following:
Code:
Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .LeftHeader = "Printed on &D"
        .CenterHeader = "Speedway Chapter 3399" & Chr(10) & "Rides 2020"
        .RightHeader = "Page &P of &N" & Chr(10) & "Ride Totals"
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
The code continues on. When I print out a particular sort, the Center Header prints Speedway Chapter 3399 & Rides 2019. When I edit the Header, it shows Rides 2019. What am I doing wrong? Do I need to remove the Header that I entered manually? Any help is appreciated.
Thank you,
Dan Wilson...
 
Last edited by a moderator:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Set PrintCommucation back to True at the end of the code to commit the changes.
 
Upvote 0
Good day shg. Thank you for responding. I wondered about your suggestion and tried it, but I'm not certain I did it right. I included the entire macro below. Maybe I didn't do it right. There are two Macros involved. the first one sorts the Rides sheet and the one below prints out the Rides totals located at the bottom of the worksheet. Everything works correctly except the Center Header.
Thank you,
Dan Wilson...
Code:
Sub Print_Ride_Totals()
'
' Print_Ride_Totals Macro
' Print Ride Totals only
' 11/27/19
'
Sheets("Rides").Select
ActiveWindow.SmallScroll Down:=128
Range("E131:H145").Select
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = "$A$1:$J$156"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = "Printed on &D"
.CenterHeader = "Speedway Chapter 3399" & Chr(10) & "Rides 2020"
.RightHeader = "Page &P of &N" & Chr(10) & "Ride Totals"
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.7)
.RightMargin = Application.InchesToPoints(0.7)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = "$E$131:$H$145"
Range("E131").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Call Reset_to_Generic
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,894
Members
452,948
Latest member
Dupuhini

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