Autofilter - 3 conditions

D

Darin Kramer

Hi There,

I have written a macro that selects from column D, using autofilter TWO
sets of data and copies and pastes it into a new book. Problem is I now
need to filter data for three conditions, ie condition 1 or condition 2
or condition 3. Excel autofilter only seems to have to custom filters...
Im sure it can be done in VB....
My original code is below, any help graciously accepted...

Thanks

D

Sub test()


With Sheets("a").Range("A1:e150")
.AutoFilter Field:=4, Criteria1:="1", Operator:=xlOr, _
Criteria2:="=2"
.SpecialCells(xlCellTypeVisible).Copy _

Sheets.Add
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
Cells.Select
Selection.RowHeight = 15
ActiveWindow.Zoom = 80
ActiveSheet.Name = "a_new"


'Now remove the autofilter
.AutoFilter



End With


End Sub
 
J

Jef Gorbach

suggestion: filter a helper column counting conditions met. (ie: if
condition1 true Col(z)=1, +1 if condition2 also true, +1 if condition3 also
true, etc then autofilter col(z)># of conditions met))
 
D

Darin Kramer

Hi Ron,

Good solution, but ... unfortunately it has to run on an unknown number
of users machines, so I cant install an add in on each of their
machines....
 
D

Darin Kramer

I need to run a Macro to do this, because users who need to use the file
do not know how to run an advanced autofilter. One Macro is running to
clean up all the data, and the sort according to three condtions is one
part of the Macro. ie, I need the VBA to be able to sort via the three
conditions...

Thanks

D :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top