ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with autofilter and filtering a specific column (https://www.excelbanter.com/excel-programming/437878-help-autofilter-filtering-specific-column.html)

Drew[_11_]

Help with autofilter and filtering a specific column
 
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.

OssieMac

Help with autofilter and filtering a specific column
 
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


--
Regards,

OssieMac



All times are GMT +1. The time now is 02:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com