ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Print conditional worksheets (https://www.excelbanter.com/excel-discussion-misc-queries/49411-print-conditional-worksheets.html)

jhicsupt

Print conditional worksheets
 
I would like to print worksheets depending on the value of B2 (in Sheet1).

If B2 = "pens" or "paper"
Then print Sheet1, Sheet3 and Sheet4

If B2 = "pencils"
Then print Sheet1, Sheet5

Any suggestions on how to do this?

Thanks in advance.

Ron de Bruin

Hi

Try this macro

Sub Tetst()
With Sheets("Sheet1")
If .Range("B2") = "pens" Or .Range("B2") = "paper" Then
Sheets(Array("Sheet1", "Sheet3", "Sheet4")).PrintOut
ElseIf .Range("B2") = "pencils" Then
Sheets(Array("Sheet1", "Sheet5")).PrintOut
End If
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"jhicsupt" wrote in message ...
I would like to print worksheets depending on the value of B2 (in Sheet1).

If B2 = "pens" or "paper"
Then print Sheet1, Sheet3 and Sheet4

If B2 = "pencils"
Then print Sheet1, Sheet5

Any suggestions on how to do this?

Thanks in advance.




Ian

Untested, but try this

Sub conditional_print_sheets()
If Range("B2").Value = "pens" Then
Worksheets("Sheet3").PrintOut
Worksheets("Sheet4").PrintOut
ElseIf Range("B2").Value = "paper" Then
Worksheets("Sheet3").PrintOut
Worksheets("Sheet4").PrintOut
ElseIf Range("B2").Value = "penclis" Then
Worksheets("Sheet4").PrintOut
End If
End Sub

--
Ian
--
"jhicsupt" wrote in message
...
I would like to print worksheets depending on the value of B2 (in Sheet1).

If B2 = "pens" or "paper"
Then print Sheet1, Sheet3 and Sheet4

If B2 = "pencils"
Then print Sheet1, Sheet5

Any suggestions on how to do this?

Thanks in advance.





All times are GMT +1. The time now is 06:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com