Excel Help Please
Author
Discussion

Davie_GLA

Original Poster:

6,888 posts

230 months

Wednesday 29th April 2020
quotequote all
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

Troubleatmill

10,210 posts

190 months

Wednesday 29th April 2020
quotequote all
Why not have 3 worksheets - each with different headers.

All the cells in sheet 2 & 3 - = contents in Sheet 1


Print Workbook to pdf or printer.


Jon Jobbed.

Davie_GLA

Original Poster:

6,888 posts

230 months

Wednesday 29th April 2020
quotequote all
I would.need.to copy the.content over though, to get three identical orders but with different headers.

Davie_GLA

Original Poster:

6,888 posts

230 months

Wednesday 29th April 2020
quotequote all
Although I guess I can use some logic to go get the same data in the first workbook cells. That could work.

Troubleatmill

10,210 posts

190 months

Wednesday 29th April 2020
quotequote all
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.