I have 3 total cells I need to check for data and then print the appropriate data sheets. When all the 3 total cells contain data it works, but when any other total cells contain no data it doesn't work.
'Turn screen off while printing
Application.ScreenUpdating = False
'Go to the Daily Data Sheet
Application.Goto (Worksheets("DAILY DATA SHEETS").Range("$A$1"))
'Check to see if there is any data in the total cells of ALL 3 sections. If true print ALL 3 Data Ranges. If False skip this section.
If Range("$B$39") > 0 And Range("$I$39") > 0 And Range("$R$39") > 0 Then
ActiveSheet.PageSetup.PrintArea = "'DATA SHEETS'!$B$2:$H$39"
End If
'Check to see if there is any data in the total cells of ALL 3 sections. If first 2 total cells test true, print them. If False skip this section.
If Range("$B$39") > 0 And Range("$I$39") > 0 And Range("$R$39") < 0 Then
ActiveSheet.PageSetup.PrintArea = "'DATA SHEETS'!$B$2:$H$39"
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
ActiveSheet.PageSetup.PrintArea = "'DAILY DATA SHEETS'!$I$2:$P$39"
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
End If
'Check to see if there is any data in the total cells of ALL 3 sections. If first total cell tests true, print it. If False skip this section.
If Range("$B$39") > 0 And Range("$I$39") < 0 And Range("$R$39") < 0 Then
ActiveSheet.PageSetup.PrintArea = "'DATA SHEETS'!$B$2:$H$39"
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
End If 'Turn screens updating back on after printing Application.ScreenUpdating = True
Aucun commentaire:
Enregistrer un commentaire