Printing with Excel Macro in Visual Basic

Closed
zessie Posts 1 Registration date Sunday July 11, 2010 Status Member Last seen July 11, 2010 - Jul 11, 2010 at 02:36 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Jul 18, 2010 at 10:24 PM
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

Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Jul 18, 2010 at 10:24 PM
What do you mean by printing conditionally ?
0