make the auto-filter work with field 1 and 3

exceltadpole

Board Regular
Joined
Jan 14, 2004
Messages
108
I am using 3 filters:

Selection.AutoFilter Field:=1, Criteria1:="=*PAID*", Operator:=xlAnd
to select all the rows which contain PAID in column 1

Selection.AutoFilter Field:=1, Criteria1:="<>*PAID*", Operator:=xlAnd
to select all the rows which do not contain PAID in column 1

Selection.AutoFilter Field:=3, Criteria1:="=*INVOICE*", Operator:=xlAnd
to select all the rows which contain INVOICE in column 3


How do I combine these into 2 filters:

to select all the rows which contain INVOICE in column 3 AND contain PAID in column 1

to select all the rows which contain INVOICE in column 3 AND do not contain PAID in column 1


(I don't know how to make the auto-filter work with different columns. Meaning field 1 and 3.)
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

al_b_cnu

Well-known Member
Joined
Jul 18, 2003
Messages
4,526
Hi,

Cant you simply use something like
---------------------------------------------------------------------
Dim sFilter as String
. . .

If ????? then
sFilter="=*PAID*"
Else
sFilter = "<>*PAID*"
End if
Selection.AutoFilter Field:=1, Criteria1:=SFilter, Operator:=xlAnd
Selection.AutoFilter Field:=3, Criteria1:="=*INVOICE*", Operator:=xlAnd
---------------------------------------------------------------------------

HTH

Alan
 

GorD

Well-known Member
Joined
Jan 17, 2004
Messages
1,447
The auto filter should do exactly as you require. it works for AND conditions across different columns.
You just select your criteria from the drop down list in your first column, then do the same on your second criteria column.

If you wanted an OR condition (across columns) you would have to use an advanced filter
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,088
Messages
5,857,290
Members
431,869
Latest member
Avinashz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top