Conditional Print Macro II

newclasshero

New Member
Joined
Sep 1, 2006
Messages
46
So my first question was answered about Conditional Printing. I decided that I would like to take it to the next step and nest another IF into the macro. However it seems that it still prints runs the first 2 macros and not just the single macro that fits the condition. Please tell me what I am doing wrong.


Sub Print_All()
'
' Print_All Macro
' Prints all necessary pages of IVIS.
'
' Keyboard Shortcut: Ctrl+Shift+P
'
If Sheets("V I S").Range("G4") = "BRIAN" Then

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
Sheets("Endsheet").PrintOut From:=5, To:=6
Sheets("Endsheet").PrintOut From:=8, To:=9
Sheets("Fax Dealer").PrintOut From:=4, To:=4
Sheets("Fax Dealer").PrintOut From:=3, To:=3
Sheets("FAX C.B. - OCI").PrintOut From:=3, To:=3
Sheets("FAX Currency-Tag").PrintOut From:=4, To:=4

If Sheets("V I S").Range("G4") = "EXECUTIVE" Then
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:=5, To:=5
Sheets("Endsheet").PrintOut From:=5, To:=6
Sheets("Fax Dealer").PrintOut From:=4, To:=4
Sheets("Fax Dealer").PrintOut From:=3, To:=3
Sheets("FAX C.B. - OCI").PrintOut From:=3, To:=3
Sheets("FAX Currency-Tag").PrintOut From:=4, To:=4

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
Sheets("Endsheet").PrintOut From:=5, To:=6
Sheets("Fax Dealer").PrintOut From:=4, To:=4
Sheets("Fax Dealer").PrintOut From:=3, To:=3
Sheets("FAX C.B. - OCI").PrintOut From:=3, To:=3
Sheets("FAX Currency-Tag").PrintOut From:=4, To:=4
End If
End If
End Sub
 

Some videos you may like

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

newclasshero

New Member
Joined
Sep 1, 2006
Messages
46
To add to this if the is nothing in cell G4 then it comes up with error message: Block If without End If. I know that sounds simple but I am new an cannot figure it out.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,406
Messages
5,547,759
Members
410,811
Latest member
adustin42
Top