Forum

Is it possible to j...
 
Notifications
Clear all

Is it possible to just exclude a value from a filter without specifying all the other values that are included?

4 Posts
2 Users
0 Reactions
682 Views
(@gobsheite)
Posts: 11
Active Member
Topic starter
 

Is it possible to just exclude a value from a filter without specifying all the other values that are included?

I want to include all values, except "Closed/Transferred"

I want to use it on many sheets I use, in all cases the other values vary, and even the "Closed/Transferred" is not always field 7

This is a recording:

ActiveSheet.ListObjects("InputTable4").Range.AutoFilter Field:=7, Criteria1 _
:=Array("1. Allocated", "2. Assessment Ongoing", _
"3. Assessment Completed, Ongoing Work", "4. Support Planning", "5. To Be Closed" _
, "6. Safeguarding/VARM/COP/Finance", "7. On Recovery Plan", "="), Operator:= _
xlFilterValues

 
Posted : 18/06/2022 4:03 am
(@debaser)
Posts: 837
Member Moderator
 

Yes, you can simply use the <> operator:

 

ActiveSheet.ListObjects("InputTable4").Range.AutoFilter Field:=7, Criteria1:="<>Closed/Transferred"

 
Posted : 18/06/2022 8:04 am
(@gobsheite)
Posts: 11
Active Member
Topic starter
 

That looks great, I just want to exclude values that are "<>Closed/Transferred"

 

but what is the referral to Field 7???

Ive tried deleting it but it generates an error?

Any ideas?

Edit:

The field heading is always "Current Stage in Process", but not always 7

"

 
Posted : 21/06/2022 10:41 am
(@debaser)
Posts: 837
Member Moderator
 

Your existing code used Field:=7 so I used the same. If your table layout might change, then you can get the index from the listcolumn like so:

 

Dim tb as Listobject

set tb = ActiveSheet.ListObjects("InputTable4")

tb.Range.AutoFilter Field:=tb.listcolumns("Current Stage in Process").index, Criteria1:="<>Closed/Transferred"

 
Posted : 21/06/2022 12:30 pm
Share: