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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,455
Messages
6,124,937
Members
449,196
Latest member
Maxkapoor

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
Back
Top