Excel Help Please
Discussion
Evening all. I'm trying to do something with an order form that I've got.
It's a basic form, nothing fancy but I want a way to print it and change the header over 3 copies to say something like "Customer", "Office", "delivery" for example.
I'm almost there after following the below link and VB code but it needs me to hit print three times and if printing to PDF then this will mean three different files for the same order. Ideally I would like something that simply created a 3 page PDF and sent it to a printer for the hard copies.
https://www.extendoffice.com/documents/excel/4324-...
Sub DifferentHeaderFooter()
Dim ws As Worksheet
Dim vLeft As Variant, vRight As Variant, xRg As Variant
Set ws = ActiveSheet
On Error Resume Next
vLeft = Array("Office", "Driver", "Customer")
xRg = Array("A1:J26", "A1:J26", "A1:J26")
Application.ScreenUpdating = False
For i = 0 To UBound(vLeft)
With ws.PageSetup
.PrintArea = xRg(i)
.LeftHeader = vLeft(i)
End With
ws.PrintPreview
Next i
Application.ScreenUpdating = True
ws.PageSetup.PrintArea = ""
End Sub
It's a basic form, nothing fancy but I want a way to print it and change the header over 3 copies to say something like "Customer", "Office", "delivery" for example.
I'm almost there after following the below link and VB code but it needs me to hit print three times and if printing to PDF then this will mean three different files for the same order. Ideally I would like something that simply created a 3 page PDF and sent it to a printer for the hard copies.
https://www.extendoffice.com/documents/excel/4324-...
Sub DifferentHeaderFooter()
Dim ws As Worksheet
Dim vLeft As Variant, vRight As Variant, xRg As Variant
Set ws = ActiveSheet
On Error Resume Next
vLeft = Array("Office", "Driver", "Customer")
xRg = Array("A1:J26", "A1:J26", "A1:J26")
Application.ScreenUpdating = False
For i = 0 To UBound(vLeft)
With ws.PageSetup
.PrintArea = xRg(i)
.LeftHeader = vLeft(i)
End With
ws.PrintPreview
Next i
Application.ScreenUpdating = True
ws.PageSetup.PrintArea = ""
End Sub
Davie_GLA said:
I would.need.to copy the.content over though, to get three identical orders but with different headers.
No you wouldn't.You just need to set a formula in a cell in sheet2 to say =sheet1(cell ref).
OK - You might need a little bit of - if null value stuff...
But then you can copy and paste that one cell for the whole sheet
Anything that appears in sheet1 cell a10 , will appear in sheet2 cell a10, ditto for sheet 3
Or just a macro - to erase all cells (except first row) in sheet 2 and 3 - and then copy all cells ( except first row) - into sheet 2 and sheet3 and print workbook.
Job done in under 2 minutes.
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


