I have a workbook, which I want to create a macro button to populate headers on certain worksheets in the workbook.
I have a macro button created in another workbook which works perfect. I figured I could copy and paste the code of the macro into this new workbook and edit it as I see fit.
Well I did all of this and it is not working.
All I am simply trying to do is populate the left and center header of 3 sheets.
The main sheet where i plug in the info for the headers is called "Headers".
The info I want to populate my headers are in rangers B2 through B10. I manually plug in my info then hit the "headers" button and all of the headers automatically populate. It is a huge timesaver in the other workbook where I have a lot more headers to fill in.
Below is the code after I edited it for this new workbook:
I have a macro button created in another workbook which works perfect. I figured I could copy and paste the code of the macro into this new workbook and edit it as I see fit.
Well I did all of this and it is not working.
All I am simply trying to do is populate the left and center header of 3 sheets.
The main sheet where i plug in the info for the headers is called "Headers".
The info I want to populate my headers are in rangers B2 through B10. I manually plug in my info then hit the "headers" button and all of the headers automatically populate. It is a huge timesaver in the other workbook where I have a lot more headers to fill in.
Below is the code after I edited it for this new workbook:
Code:
Sub Headers()
Dim Headers As Worksheet
Dim Master As Worksheet
Dim InsulationProgress As Worksheet
Dim CoatingsProgress As Worksheet
Dim JobDesc As Range
Dim Insul As Range
Dim Paint As Range
Set Headers = Worksheets("Headers")
Set CostWorksheet = Worksheets("Cost Work Sheet")
Set Ins = Worksheets("Insulation Progress")
Set Coat = Worksheets("Coatings Progress")
Set Master = Worksheets("Master")
Set JobDesc = Headers.Range("B2")
Set Insul = Headers.Range("B3")
Set Paint = Headers.Range("B4")
Set Insul = Headers.Range("B5")
Set Paint = Headers.Range("B6")
Set Insul = Headers.Range("B7")
Set Paint = Headers.Range("B7")
Set Paint = Headers.Range("B8")
Set Insul = Headers.Range("B9")
On Error GoTo errExit
Application.ScreenUpdating = False
Application.EnableEvents = False
Ins.Activate
With Ins.PageSetup
.LeftHeader = "&""Arial,Bold""&18ASBESTOS: " & Insul
.CenterHeader = "&""Arial,Bold""&18" & JobDesc & Chr(10) & "&10Insulation Progress"
End With
Coat.Activate
With Coat.PageSetup
.LeftHeader = "&""Arial,Bold""&18LEAD: " & Encl & Chr(10) & "WO # " & Surf & Chr(10) & "&18COATING JOB # " & Coating
.CenterHeader = "&""Arial,Bold""&18" & JobDesc & Chr(10) & "&10Coatings Progress"
End With
Master.Activate
With MainCoverSheet.PageSetup
.CenterHeader = "&""Arial,Bold""&18" & JobDesc & Chr(10) & "&16Master" & Chr(10)
End With
errExit:
Headers.Activate
MsgBox "Headers Update Completed!"
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Last edited by a moderator: