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.)
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

al_b_cnu

Well-known Member
Joined
Jul 18, 2003
Messages
4,494
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,446
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,564
Messages
5,596,875
Members
414,106
Latest member
Tigretto

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