Hi All,
I have a 11 Page document that needs some, not all the pages printed at times. I have a toggle on each page for "Yes" to print or "No" not to print. Im new to VBA so forgive the poor excuse of a "code" Im about to post. I dont know of a better way to do this but I was hoping to use if/then combos to build a print area.
Sub testing()
'
' testing Macro
ActiveSheet.PageSetup.PrintArea = "A120:EF357" & _ '// Page 1 - 2
If ActiveSheet.Range("EK366").Value = "Yes" Then
Result = "A358:EF595" '// Page 3 -4
Else = "A477:EF595" '// Page 4
End If
If ActiveSheet.Range("EL603").Value = "Yes" Then
Result = "A596:EF714" '// Page 5
Else = ""
End If
If ActiveSheet.Range("EK722").Value = "Yes" Then
Result = "A715:EF833" '// Page 6
Else = ""
End If
If ActiveSheet.Range("EM842").Value = "Yes" Then
Result = "A834:EF952" '// Page 7
Else = ""
End If
If ActiveSheet.Range("EK960").Value = "Yes" Then
Result = "A953:EF1309" '// Page 8 -11
Else = "A1072:EF1309" '// Page 9 -11
End If
End Sub
Let me know what you guys think. Im not opposed to suggestions if you have a better way of working this out. Currently we print everything out and delete the extra pages.
I have a 11 Page document that needs some, not all the pages printed at times. I have a toggle on each page for "Yes" to print or "No" not to print. Im new to VBA so forgive the poor excuse of a "code" Im about to post. I dont know of a better way to do this but I was hoping to use if/then combos to build a print area.
Sub testing()
'
' testing Macro
ActiveSheet.PageSetup.PrintArea = "A120:EF357" & _ '// Page 1 - 2
If ActiveSheet.Range("EK366").Value = "Yes" Then
Result = "A358:EF595" '// Page 3 -4
Else = "A477:EF595" '// Page 4
End If
If ActiveSheet.Range("EL603").Value = "Yes" Then
Result = "A596:EF714" '// Page 5
Else = ""
End If
If ActiveSheet.Range("EK722").Value = "Yes" Then
Result = "A715:EF833" '// Page 6
Else = ""
End If
If ActiveSheet.Range("EM842").Value = "Yes" Then
Result = "A834:EF952" '// Page 7
Else = ""
End If
If ActiveSheet.Range("EK960").Value = "Yes" Then
Result = "A953:EF1309" '// Page 8 -11
Else = "A1072:EF1309" '// Page 9 -11
End If
End Sub
Let me know what you guys think. Im not opposed to suggestions if you have a better way of working this out. Currently we print everything out and delete the extra pages.
Last edited: