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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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
 
Upvote 0
'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
 
Upvote 0
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.)
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,517
Members
448,968
Latest member
Ajax40

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
Back
Top