PMRetired2012
Board Regular
- Joined
- Aug 6, 2019
- Messages
- 123
What im wondering is there a way to shorten the code for these lines of code that i have written and get the same outcome. What i want to do is only print pages that have something in cell A3 and S3 and then i want it to print both pages. Here is the code i have writen>
If OptionButton2 = True Then
Dim A As Integer
A = 1
For A = 1 To 12
Sheets(A).Select
If WorksheetFunction.CountA(ActiveSheet.Range("A3:A54")) <> 0 Then
Range("A1:R54").Select
'PrintPreview
If CheckBox3.Value = True Then ExecuteExcel4Macro "PRINT(1,,,1,,TRUE,,,,,,1,,,TRUE,,FALSE)"
'Print
If CheckBox3.Value = False Then ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,1,,,TRUE,,FALSE)"
Else
A = A + 1
End If
Next A
If CheckBox1.Value = True Then
Dim B As Integer
B = 1
For B = 1 To 12
Sheets(B).Select
If WorksheetFunction.CountA(ActiveSheet.Range("S3:S54")) <> 0 Then
Range("S1:AL54").Select
'PrintPreview
If CheckBox3.Value = True Then ExecuteExcel4Macro "PRINT(1,,,1,,TRUE,,,,,,1,,,TRUE,,FALSE)"
'Print
If CheckBox3.Value = False Then ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,1,,,TRUE,,FALSE)"
Else
B = B + 1
End If
Next B
If OptionButton2 = True Then
Dim A As Integer
A = 1
For A = 1 To 12
Sheets(A).Select
If WorksheetFunction.CountA(ActiveSheet.Range("A3:A54")) <> 0 Then
Range("A1:R54").Select
'PrintPreview
If CheckBox3.Value = True Then ExecuteExcel4Macro "PRINT(1,,,1,,TRUE,,,,,,1,,,TRUE,,FALSE)"
If CheckBox3.Value = False Then ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,1,,,TRUE,,FALSE)"
Else
A = A + 1
End If
Next A
If CheckBox1.Value = True Then
Dim B As Integer
B = 1
For B = 1 To 12
Sheets(B).Select
If WorksheetFunction.CountA(ActiveSheet.Range("S3:S54")) <> 0 Then
Range("S1:AL54").Select
'PrintPreview
If CheckBox3.Value = True Then ExecuteExcel4Macro "PRINT(1,,,1,,TRUE,,,,,,1,,,TRUE,,FALSE)"
If CheckBox3.Value = False Then ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,1,,,TRUE,,FALSE)"
Else
B = B + 1
End If
Next B