Hey all,
I'll give you background and then the issue.
I've created a userform that does 2 things. 1st it copies selected worksheets to a new workbook using if then statements with check boxes
2nd it inputs the header and footer with relevant information that I input in the user form. (see figure 2 for a part of the user form).
The Problem: the user form works great. The date and page numbers populate in the footer in the new worksheets. But the left and right header do not populate with the user form values as I coded (figure 2). So instead I used this code (figure 3) to resolve this for now, but its SLOW and clunky. Can you suggest something to make it pull from the original figure 2 code? Thanks!
Figure 1
Untitled.png
Figure 2 (red is code that doesn't work as described and green works as desired)
"Sub header()
' header Macro
ActiveWindow.View = xlPageLayoutView
With ActiveWorkbook.PageSetup
.LeftHeader = UserForm1.MultiPage1.Pages("page1").Frame1.TextBox1.Value & Chr(10) & UserForm1.MultiPage1.Pages("page1").Frame1.TextBox2.Value
.CenterHeader = ""
.RightHeader = UserForm1.MultiPage1.Pages("page1").Frame1.TextBox3.Value & Chr(10) & UserForm1.MultiPage1.Pages("page1").Frame1.TextBox4.Value
.LeftFooter = "&D"
'.CenterFooter = ""
.RightFooter = "Page &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)
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
'.PrintErrors = xlPrintErrorsDisplayed
'.OddAndEvenPagesHeaderFooter = False
'.DifferentFirstPageHeaderFooter = False
'.ScaleWithDocHeaderFooter = True
'.AlignMarginsHeaderFooter = True
End With
ActiveWindow.View = xlNormalView
End Sub"
Figure 3
" Dim ws As Worksheet
For Each ws In Worksheets
wb.Activate
' Formating Header of each sheet in the newly created workbook
Call header
Next ws
Worksheets(1).Activate"
Bookmarks