Hello,
I am trying to write a VBA code that allows me to print multiple sheets to a PDF - requirements are as follows:
This means that for Sheet2 to Sheet1**, they will only form part of the PDF if the cell value in the index is >0. The same value appears in every tab as cell C2, so could use that as a reference.
For example:
In this case I would want to print Sheet1 as index, but also Sheet2 and Sheet4 based on the cell values of the index.
I tried using
But that considers all sheets and Sheet1 should be excluded as always printed
I also have following code which is probably still useful:
Any advice would be appreciated!
I am trying to write a VBA code that allows me to print multiple sheets to a PDF - requirements are as follows:
- Sheet1 is an index.
- Column B contains a list of all other Sheet names in column 2 as hyperlinks (about 120 other sheets)
- Column C contains numerical values which relate to each of these sheets
- I want to be able to print one PDF with the following
- Index at front every time (Sheet1)
- Print all other sheets if Column C in Sheet1 contains a value >0
This means that for Sheet2 to Sheet1**, they will only form part of the PDF if the cell value in the index is >0. The same value appears in every tab as cell C2, so could use that as a reference.
For example:
In this case I would want to print Sheet1 as index, but also Sheet2 and Sheet4 based on the cell values of the index.
I tried using
VBA Code:
For Each ws In Worksheets
But that considers all sheets and Sheet1 should be excluded as always printed
I also have following code which is probably still useful:
Code:
'Grouping selected worksheets
Worksheets(Split(Left(strWS, Len(strWS) - 1), cstrDel)).Select
'Printing to PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=ActiveWorkbook.Path & "\" & "TestPrintAllActiveToPDF" & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Any advice would be appreciated!