View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Autofilter Printing

You said based on the month that you choose.

So that choice would be held in sMonth and yes, sMonth should be declared
and an appropriate value assigned to it.

I was just illustrating that you would apply this criteria to the
appropriate column of the autofilter.


Dim sMonth as String

sMonth = "February"
For Each itm In noDupes
Selection.AutoFilter Field:=5, Criteria1:=itm
Selection.AutoFilter Field:=6, Criteria1:=sMonth
ActiveSheet.AutoFilter.Range.PrintPreview
Next

is just illustrative. You would have to adapt it to your situation.
--
Regards,
Tom Ogilvy
..


"Magoo" wrote in message
ups.com...

Magoo wrote:
Tom Ogilvy wrote:
For Each itm In noDupes
Selection.AutoFilter Field:=5, Criteria1:=itm
Selection.AutoFilter Field:=6, Criteria1:=sMonth
ActiveSheet.AutoFilter.Range.PrintPreview

Next

--
Regards,
Tom Ogilvy



"Magoo" wrote in message
oups.com...
Using the following code, I am able to automatically print (title5
Column) autofilter results
based on the autofilters of a designated column, so that I don't have
to select each autofilter one at a time and print.
__________________________________________________ ______________________

Sub abc()
Dim noDupes As New Collection
Dim rw As Long
Dim itm As Variant
Selection.AutoFilter Field:=5
rw = ActiveSheet.AutoFilter.Range.Row
For Each cell In ActiveSheet.AutoFilter.Range.Columns(5).Cells
If cell.Row < rw Then
On Error Resume Next
noDupes.Add cell.Value, cell.Text
On Error GoTo 0
End If
Next
For Each itm In noDupes
Selection.AutoFilter Field:=5, Criteria1:=itm
ActiveSheet.AutoFilter.Range.PrintPreview
Next
__________________________________________________ ______________________


I would now like to add a function to the macro that would allow me
to
print those same results based on the month that I choose.


Example Below:
Name Title 2 Title 3 Title 4 Title 5 Month
Data 1 101 10 101 Unique Data1 February
Data 2 101 10 101 Unique Data1 February
Data 3 101 10 101 Unique Data2 February
Data 4 101 10 101 Unique Data3 March
Data 5 101 10 101 Unique Data4 March
Data 6 101 10 101 Unique Data5 April
Data 7 101 10 101 Unique Data1 May


Is there a way to do this?
Hello Tom you have come to my rescue again. Thanks I will try this
right away.


Hello Tom. I know that I did something wrong or omitted something. Here
is what I have.

Sub abc()
Dim noDupes As New Collection
Dim rw As Long
Dim itm As Variant
Selection.AutoFilter Field:=5
rw = ActiveSheet.AutoFilter.Range.Row
For Each cell In ActiveSheet.AutoFilter.Range.Columns(5).Cells
If cell.Row < rw Then
On Error Resume Next
noDupes.Add cell.Value, cell.Text
On Error GoTo 0
End If
Next
For Each itm In noDupes
Selection.AutoFilter Field:=5, Criteria1:=itm
Selection.AutoFilter Field:=6, Criteria1:=sMonth
ActiveSheet.AutoFilter.Range.PrintPreview
Next

should I Dim sMonth?