Forum Discussion
dshawSLDC
Jun 25, 2021Brass Contributor
Print macro to check if data is there before printing
Hello, So I am using a macro to print specific sheets in a workbook. These sheets are filled based on a let Formula. I am trying to figure out hot to make it check if there is data before it prints....
dshawSLDC
Jun 28, 2021Brass Contributor
This is what Im working with now but I am getting errors.
Sub check()
With Sheets("invoice pg.2")
If WorksheetFunction.CountA(Sheets("Invoice pg.2").Range("B14")) = 0 Then
Sheets("Invoice").Select
Sheets("Invoice").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Else
With Sheets("invoice pg.3")
If WorksheetFunction.CountA(Sheets("Invoice pg.3").Range("B14")) = 0 Then
Sheets(Array("Invoice", "Invoice pg.2")).Select
Sheets("Invoice").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Else
With Sheets("invoice pg.4")
If WorksheetFunction.CountA(Sheets("Invoice pg.4").Range("B14")) = 0 Then
Sheets(Array("Invoice", "Invoice pg.2", "Invoice pg.3")).Select
Sheets("Invoice").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Else
Sheets(Array("Invoice", "Invoice pg.2", "Invoice pg.3", "invoice pg.4")).Select
Sheets("Invoice").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets(Array("Invoice", "Invoice pg.2", "Invoice pg.3", "Invoice pg.4")).Select
End If
End If
End If
End With
End Sub
Can anyone point me in the right direction?