Printing with Excel Macro in Visual Basic

[Closed]
Report
Posts
1
Registration date
Sunday July 11, 2010
Status
Member
Last seen
July 11, 2010
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
Hello,

Hi,

Newbie at macro here..help!!

How do you do conditional printing of worksheets for macro (using recorded macro)?
Bacially I have to print for A-E(total of 5) under heading (cell D161).
Sometimes, I do not need to print for all 5 as there maybe only information for A-B and E,
no information for C and D.

Hence I should do a for or if/else loop to run?
What is e proper syntax?
Thanks.

Below is a sample of my recorded macro.

Code:

Selection.AutoFilter Field:=4, Criteria1:="A"
Range("D161").Select
ActiveWindow.View = xlPageBreakPreview
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWindow.View = xlNormalView
Selection.AutoFilter Field:=4, Criteria1:="B"
ActiveWindow.View = xlPageBreakPreview
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Selection.AutoFilter Field:=4, Criteria1:="C"
ActiveWindow.View = xlPageBreakPreview
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Selection.AutoFilter Field:=4, Criteria1:="D"
ActiveWindow.View = xlPageBreakPreview
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Selection.AutoFilter Field:=4, Criteria1:="E"
ActiveWindow.View = xlPageBreakPreview
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

1 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
What do you mean by printing conditionally ?