VBA code to Autofilter for "Everything, but certain values"

epb613

New Member
Joined
Feb 18, 2010
Messages
14
Hi I work in Software testing and each morning I like to export the defect log into Excel.

I created a macro to format everything nicely and autofilter for active defects, but I find that every week or two I have another value to the filter list (new defect statutes get created periodically).

What I really want to do is autofilter for everything EXCEPT "Closed" and "Canceled". Is there a way to do that?

Here's my current autofilter line:
Code:
    Defect_Table.AutoFilter Field:=2, Criteria1:=Array("In Coding - Tech", _
        "New", "Ready for Retest", "Ready for Tech", "Retest Failed", _
            "Retest Passed", "Watch", "Researching - Tech", _
                "Researching - Admin"), Operator:=xlFilterValues

Instead of adding the values I want shown, I want to add the values that I want hidden, since the shown list keeps changing but the hidden list stays static (just Closed and Canceled). Is this possible?

Thanks!
Pinny
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Something along the lines of

Dim c As Range, rng
Set rng = Range("a1:a100")
For Each c In rng
If c.Value = "Closed" Or c.Value = "Cancelled" Then
c.EntireRow.Hidden = True
End If
Next c
 
Upvote 0
Hey Steve, that's a neat idea, and I'll definitely keep that code in my toolbox for the future.

Here's the "proper" way to do it though. (I found this by using record macro - duh!)
Code:
Defect_Table.AutoFilter Field:=2, Criteria1:="<>Closed", Criteria2:="<>Canceled"
 
Upvote 0
Hy,

If I would like to filter without 3 criteria ?

Thanks.

Hey Steve, that's a neat idea, and I'll definitely keep that code in my toolbox for the future.

Here's the "proper" way to do it though. (I found this by using record macro - duh!)
Code:
Defect_Table.AutoFilter Field:=2, Criteria1:="<>Closed", Criteria2:="<>Canceled"
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,987
Members
452,373
Latest member
TimReeks

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