Help with autofilter and filtering a specific column

D

Drew

in a macro that filters a specific column i have the following code...

ActiveSheet.Range("A7:CQ199").AutoFilter Field:=31, Criteria1:="=3",
_
Operator:=xlOr, Criteria2:="=4"

however, i have since given everything named ranges to make the table
more dynamic (so i dont have to modify my code everytime i add a
column or another row of data). so what i want to filter is column AE
(hence field 31). i named it ("AE7:AE199") "list"... but when i modify
the existing code to...

ActiveSheet.Range("list").AutoFilter Field:=1, Criteria1:="=3", _
Operator:=xlOr, Criteria2:="=4"

it does not work. how can i get this to work? any help is appreciated.
 
O

OssieMac

Hello Drew,

Try the following. Note that a space and underscore at the end of a line is
a line break in an otherwise single line of code.

With ActiveSheet.AutoFilter.Range

.AutoFilter Field:=1, Criteria1:="=3", _
Operator:=xlOr, Criteria2:="=4"

End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top