Crane92
Crane92

Reputation: 41

How do i filter out a specific value in VBA?

Dim rng As Range
lMaxRows = Cells(Rows.Count, "I").End(xlUp).Row`
Set rng = ActiveSheet.Range("A1:K" & lMaxRows)

FilterField = WorksheetFunction.Match("Description", rng.Rows(1), 0)

If ActiveSheet.AutoFilterMode = False Then 
    rng.AutoFilter
    rng.AutoFilter Field:=FilterField, Criteria1:=Array( _
    "GPRS Calls"), Operator:=xlFilterValues
End If

Hi, i know how to filter a specific value but how do i get it to filter so everything shows except for one value? There must be an easier way than just writing all of the values into the filter code.

Thanks for your help!

Upvotes: 0

Views: 2043

Answers (2)

luke_t
luke_t

Reputation: 2985

You can just use <> (does not equal).

Criteria1:="<>GPRS Calls"

Everything will now show in the table, except for rows with "GPRS Calls".

Upvotes: 1

Crane92
Crane92

Reputation: 41

Sorted it now. Found out that i need the <> inside the quotes and remove the array() part.

Upvotes: 0

Related Questions