Dan Wilson
Well-known Member
- Joined
- Feb 5, 2006
- Messages
- 536
- Office Version
- 365
- Platform
- Windows
Good day and Happy New Year. I hope you all had a good Christmas. I am running Excel out of Office365 (updated) on Windows 10 Home. I have a workbook that I updated for 2021 by copying the 2020 version and making necessary Macro changes. One of the changes does not seem to be working. I have copied below a portion of code that is in each Macro.
The problem is the third line of the code. Although I changed the year from 2020 to 2021, the printout of any data still shows 2020 until I manually change the year in the Page Layout function. The code is lengthy because it was created using Record Macro and mouse clicks. Is there something wrong with the code that the new year is not being changed? I have no idea what the Chr(10) is doing in the code. I appreciate any help.
Thank you,
Dan Wilson...
VBA Code:
With ActiveSheet.PageSetup
.LeftHeader = "Printed on &D"
.CenterHeader = "Speedway Chapter 3399" & Chr(10) & "Riders 2020"
.RightHeader = "Page &P of &N" & Chr(10) & "Riders by Last Name"
.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)
.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
The problem is the third line of the code. Although I changed the year from 2020 to 2021, the printout of any data still shows 2020 until I manually change the year in the Page Layout function. The code is lengthy because it was created using Record Macro and mouse clicks. Is there something wrong with the code that the new year is not being changed? I have no idea what the Chr(10) is doing in the code. I appreciate any help.
Thank you,
Dan Wilson...
Last edited by a moderator: