Hello Excel Helpers!
I am a bit stuck. I have a staff member that needs to put certain Header/Footer information on each tab when printing all/any excel documents from one of her bosses. I tried to record a macro that she can have it run on all worksheets without having to do it individually or manually but it does not work as expected.
I need the page header when printing to have the "file name - tab name" (font size 9) and the footer should have "page # of Total number of pages" (font size 9).
It will not give me the tab name if I use the left header so I moved it to the right side and it worked. And the footer shows: "as of &RPage 1 of" if there is an existing footer. The test sheet had "as of Date" in the left footer field. Even using the right footer as a test has issues. Here is the recorded code:
Any help/advice/suggestions is truly appreciated. Thank you, Kim
I am a bit stuck. I have a staff member that needs to put certain Header/Footer information on each tab when printing all/any excel documents from one of her bosses. I tried to record a macro that she can have it run on all worksheets without having to do it individually or manually but it does not work as expected.
I need the page header when printing to have the "file name - tab name" (font size 9) and the footer should have "page # of Total number of pages" (font size 9).
It will not give me the tab name if I use the left header so I moved it to the right side and it worked. And the footer shows: "as of &RPage 1 of" if there is an existing footer. The test sheet had "as of Date" in the left footer field. Even using the right footer as a test has issues. Here is the recorded code:
Code:
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = "&9&F - &A"
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = "&9Page &P of &N"
.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
Any help/advice/suggestions is truly appreciated. Thank you, Kim