I created a VBA script that will take information from SAP, extract it as an excel file, save it into a particular folder, and then prints out the sheets from the excel workbook that was created.
From the SAP data that is extracted, that data differentiates on the number of rows that are returned.
i.e.:
1st extraction: 5 rows are returned
2nd extraction: 15 rows returned.
3rd extraction: 10 rows returned. etc.
when these rows are extracted, they are then prepopulated into specific cells on multiple different sheets. If there are 5 rows, then that will only take up 3 sheets. 15 rows that will take up 10 sheets. However currently, the script is printing all the sheets even when they are empty.
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If sh.Name = "V" Or sh.Name = "W" Or sh.Name = "X" Or sh.Name = "Y" Or sh.Name = "Z" Then
sh.PrintOut Preview:=False, ActivePrinter:="Print&Go Americas", PrintToFile:=True, PrToFileName:=PSFileName
End If
Next sh
As you can see, it is printing sheets VWXY and Z. Is there a way to NOT print unfilled cells.
i.e.
if cells A1, A2, and A3 is 0, then i can for that sheet to NOT print.