Conditional Print Macro

newclasshero

New Member
Joined
Sep 1, 2006
Messages
46
I have a Workbook that contains mutiple worksheets that print out with the following macro:

Sheets("Endsheet").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True
Sheets("V I S").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True
Sheets("FAX Currency-Tag").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=3, Copies:=1, Collate _
:=True
Sheets("FAX C.B. - OCI").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True
Sheets("Fax Dealer").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=2, Copies:=1, Collate _
:=True
Sheets("FAX C.B. - OCI").Select
ActiveWindow.SelectedSheets.PrintOut From:=5, To:=5, Copies:=1, Collate _
:=True

If cell A1 in "V I S"="Brian" I need to print all of the sheets in a different order (and add a couple of extra pages not in the original macro). Any help on how to do this would be great. How would I go from a single minded macro to a if based macro. Thank you for any insight.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,884
Hi newclasshero

Please try

Code:
Sub PrintSheets()

If Sheets("V I S").Range("A1") = "Brian" Then

    ' your code to print sheets in case of brian

Else
    Sheets("Endsheet").PrintOut From:=1, To:=1
    Sheets("V I S").PrintOut From:=1, To:=1
    Sheets("FAX Currency-Tag").PrintOut From:=1, To:=3
    Sheets("FAX C.B. - OCI").PrintOut From:=1, To:=1
    Sheets("Fax Dealer").PrintOut From:=1, To:=2
    Sheets("FAX C.B. - OCI").PrintOut From:=5, To:=5
End If
End Sub

Hope this helps
PGC
 

agb136

New Member
Joined
Jan 26, 2006
Messages
34
'This might work for you

Sub PrintFile()

Sheets("V I S").Select
If Range("A1") = "Brian" Then
'<Insert the sheets in order and add the others>
Else

Sheets("Endsheet").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True

Sheets("V I S").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True

Sheets("FAX Currency-Tag").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=3, Copies:=1, Collate _
:=True

Sheets("FAX C.B. - OCI").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True

Sheets("Fax Dealer").Select
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=2, Copies:=1, Collate _
:=True

Sheets("FAX C.B. - OCI").Select
ActiveWindow.SelectedSheets.PrintOut From:=5, To:=5, Copies:=1, Collate _
:=True

End If

End Sub
 

newclasshero

New Member
Joined
Sep 1, 2006
Messages
46

ADVERTISEMENT

Thank you very much everybody. I am going to try it let you know how it goes.
 

newclasshero

New Member
Joined
Sep 1, 2006
Messages
46
Thank the code work perfectly. Since I am new and usually have no idea where to find the answers to some of my questions than you all for taking the time. (Looks like pcg01 won the race to answer the question.)
 

Forum statistics

Threads
1,136,266
Messages
5,674,721
Members
419,521
Latest member
Jasonnie

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top