ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional Printing of worksheet (https://www.excelbanter.com/excel-programming/350171-conditional-printing-worksheet.html)

Thor[_6_]

Conditional Printing of worksheet
 

Hello...
I have 2 worksheets that I need to print out based on a cell value in a
third worksheet written as a macro. Example of sheets named: Sheet1,
Sheet2, Sheet3.
Sheet1 contains the control variable in Cell A55. If a value of 1 is in
cell A55, then I wish to print only Sheet1 when the macro is run. If a
value of 2 is in this cell, then I wish to print both Sheet1 and Sheet2
when the macro is run. Simple? Maybe for the VB'ers. Any idea??

Thanx as always. Thor.


--
Thor
------------------------------------------------------------------------
Thor's Profile: http://www.excelforum.com/member.php...fo&userid=1049
View this thread: http://www.excelforum.com/showthread...hreadid=500474


Norman Jones

Conditional Printing of worksheet
 
Hi Thor,

Try something like:

'=============
Public Sub Tester001()

Dim rng As Range

Set rng = ActiveWorkbook.Sheets("Sheet1").Range("A55")

If rng.Value = 1 Then
Sheets("Sheet1").PrintOut
ElseIf rng.Value = 2 Then
Sheets(Array("Sheet1", "Sheet2")).PrintOut
End If
End Sub
'<<=============


---
Regards,
Norman


"Thor" wrote in message
...

Hello...
I have 2 worksheets that I need to print out based on a cell value in a
third worksheet written as a macro. Example of sheets named: Sheet1,
Sheet2, Sheet3.
Sheet1 contains the control variable in Cell A55. If a value of 1 is in
cell A55, then I wish to print only Sheet1 when the macro is run. If a
value of 2 is in this cell, then I wish to print both Sheet1 and Sheet2
when the macro is run. Simple? Maybe for the VB'ers. Any idea??

Thanx as always. Thor.


--
Thor
------------------------------------------------------------------------
Thor's Profile:
http://www.excelforum.com/member.php...fo&userid=1049
View this thread: http://www.excelforum.com/showthread...hreadid=500474





All times are GMT +1. The time now is 10:06 PM.

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