VBA Autofilter array question

woods2007

Board Regular
Joined
Aug 29, 2007
Messages
57
Hi,

Is there a way to use a 'not' with an array in autofilter?

I'd like to show all rows excluding those in the array.

see below code:

Sub filtertitle()

Dim lr As Long

lr = Cells(Rows.count, 1).End(xlUp).Row

[a1].CurrentRegion.Select

Selection.AutoFilter

Range(Cells(1, 1), Cells(lr, 26)).AutoFilter Field:=2, Criteria1:=Array("Mr", "Mrs", "Miss", "Ms", "Dr"), Operator:=xlFilterValues

End Sub


I have a work around by adding an additional column and filtering on my criteria and then adding a '1' in that column and then filter on NOT '1' but its a bit long winded. Is there a more direct route?

Stephen
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
No, not with an autofilter. Advanced filter can be easier to use with such situations although it does require a separate criteria range.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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