nancyma1440
New Member
- Joined
- Apr 30, 2018
- Messages
- 1
Hello,
I have an excel file:
- For the 1st 100 worksheets called "1","2","3","4","5"..."100" are the debit notes to different companies, suppose the print area is A1:G77, default print setting is 1 page
- For the 101st worksheet called "Supporting" which is the page 2 of those debit notes & normally I have to use the filter to print the different data & attach with different debit notes, suppose the print area is A1:AI352, default print setting is 1 page (as there have ~10 rows for each debit note)
- For the 102nd worksheet called "Control" which is for reference only
Actually I have tried below & also success with correct format of output
1. print all debit note to 100 pdf (i.e. 100 pdfs & 1 page/file) which print area is A1:G77
2. print all supporting to 100 pdf (i.e. 100 pdfs & 1 page/file) which print area is A1:AI352
Now I am going to do is..... create 100 pdf files which have 2 pages, 1st page is the debit note & 2nd page is the supporting.
However, per my marco below, the 1st page of the output is OK, but the 2nd page printed the range of A1:G77 only.
** if I move the command "Sheets(Array((i - 1), "Supporting")).Select" to the below of "For i = 2 To tr", then
the output have 16 pages, which 1st is the correct debit note, 2nd-15th is blank, and 16th is correct support.
Could you please help on my issue?? Million thanks.
I have an excel file:
- For the 1st 100 worksheets called "1","2","3","4","5"..."100" are the debit notes to different companies, suppose the print area is A1:G77, default print setting is 1 page
- For the 101st worksheet called "Supporting" which is the page 2 of those debit notes & normally I have to use the filter to print the different data & attach with different debit notes, suppose the print area is A1:AI352, default print setting is 1 page (as there have ~10 rows for each debit note)
- For the 102nd worksheet called "Control" which is for reference only
Actually I have tried below & also success with correct format of output
1. print all debit note to 100 pdf (i.e. 100 pdfs & 1 page/file) which print area is A1:G77
2. print all supporting to 100 pdf (i.e. 100 pdfs & 1 page/file) which print area is A1:AI352
Now I am going to do is..... create 100 pdf files which have 2 pages, 1st page is the debit note & 2nd page is the supporting.
However, per my marco below, the 1st page of the output is OK, but the 2nd page printed the range of A1:G77 only.
** if I move the command "Sheets(Array((i - 1), "Supporting")).Select" to the below of "For i = 2 To tr", then
the output have 16 pages, which 1st is the correct debit note, 2nd-15th is blank, and 16th is correct support.
Code:
Sub PDF_Combine()
tr = Sheets("Control").Range("b1").End(xlDown).Row
For i = 2 To tr
With Sheets(i - 1)
.Activate
.Range("a1:g77").Select
End With
With Sheets("Supporting")
.Activate
.Range("a1:ai350").AutoFilter 10, Sheets("Control").Range("d" & i)
.Range("a1:ai352").Select
End With
Sheets(Array((i - 1), "Supporting")).Select
Selection.ExportAsFixedFormat _
Type:=xlTypePDF, _
filename:=Sheets("Control").Range("af" & i) & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
openafterpublish:=False
Next i
End Sub
Could you please help on my issue?? Million thanks.
Last edited by a moderator: