Code Check

Miya

Well-known Member
Joined
Nov 29, 2008
Messages
662
Hi, what is wrong with this code i get application defined object errror


With Sheets("SecuritiesReport").Range("A5")
.AutoFilter Field:=4, Criteria1:="=DOMCORP", Operator:=xlOr, Criteria2:="=TEMP", _
Operator:=xlOr, Criteria3:="=UNDADMIN", Operator:=xlOr, Criteria4:="=RIGHTS", _
Operator:=xlOr, Criteria5:="=SUBMVMNT"
End With
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi

Autofilter can have only 2 criteria

.Autofilter Field:=4, Criteria1:="something", Operator:=xlOr, Criteria2:="Something else"

If you have XL2007 or higher, you can use array's in the criteria, something like....

.AutoFilter Field:=4, Criteria1:=Array("DOMCORP", "TEMP", "UNDADMIN", "RIGHTS", "SUBMVMNT"), Operator:=xlFilterValues
 
Upvote 0
I have 2002, so what can i do?

Hi

Autofilter can have only 2 criteria

.Autofilter Field:=4, Criteria1:="something", Operator:=xlOr, Criteria2:="Something else"

If you have XL2007 or higher, you can use array's in the criteria, something like....

.AutoFilter Field:=4, Criteria1:=Array("DOMCORP", "TEMP", "UNDADMIN", "RIGHTS", "SUBMVMNT"), Operator:=xlFilterValues
 
Upvote 0
The easiest way would be to have multiple filters..

Example

.Autofilter Field:=4, Criteria1:="DOMCORP", Operator:=xlOr, Criteria2:="TEMP"
'code to do some action
.Autofilter Field:=4, Criteria1:="UNDADMIN", Operator:=xlOr, Criteria2:="RIGHTS"
'code to do some action... etc

This would probably work for you since you seem to have only about 5-6 criteria.
 
Upvote 0
That did not work, i require the code to show all those teams in the filter, when i run the code it only captures the second Autofilter and removes the first one

The easiest way would be to have multiple filters..

Example

.Autofilter Field:=4, Criteria1:="DOMCORP", Operator:=xlOr, Criteria2:="TEMP"
'code to do some action
.Autofilter Field:=4, Criteria1:="UNDADMIN", Operator:=xlOr, Criteria2:="RIGHTS"
'code to do some action... etc

This would probably work for you since you seem to have only about 5-6 criteria.
 
Upvote 0
It'll be better if you could post some sample data and tell us what exactly you are trying out along with expected results.
 
Upvote 0
It'll be better if you could post some sample data and tell us what exactly you are trying out along with expected results.

I have source codes in Col d, i need the code to filter for these criterias if they are there, so i want to see all those teams in the filter.

Code:
    With Sheets(1).Range("A5")
            .AutoFilter Field:=4, Criteria1:="DOMCORP", Operator:=xlOr, Criteria2:="TEMP"
            .AutoFilter Field:=4, Criteria1:="UNDADMIN", Operator:=xlOr, Criteria2:="RIGHTS"
        End With
 
Upvote 0
If you are willing to use an extra column, there can be a workaround to this.

In E2 (assuming Column E is empty and data starts from row 2)

=ISNUMBER(MATCH(D2,{"DOMCORP","TEMP","UNDADMIN","RIGHTS","SUBMVMNT"},0))

Copy down.

Now filter on column E for TRUE instead of multiple criteria in column D
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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