rjplante
Well-known Member
- Joined
- Oct 31, 2008
- Messages
- 574
- Office Version
- 365
- Platform
- Windows
I am trying to set up a filter that will use the text from a cell to filter on. I have a user form that the user will select the product to filter for. This is recorded in cell EG1. I have a vlookup formula in cell EG2 that displays the info in the second column of a table with the filter criteria. If the user selects product A, the cell will display, "Tool 1", "Tool 2", "Tool 3" (with quotes and commas). This is the format of the criteria section of the filter in some of my previous filters macros. I have those hard coded, but this is using a vlookup and a cell reference to execute the filter. When I run it, it does not apply the filter to the column and I get no rows returned. What am I missing?
Thanks for any help to get this working.
Robert
Code:
Dim IFilterCell, AFilterCell As Range
IFilterCell = Sheets("Investigation Tasks").Range("EG2").Value
'filter for Status - Investigation is New (Column E = 5)
ActiveSheet.Range("$A$2:$AL2" & lastrow).AutoFilter Field:=5, Criteria1:="New"
' Filter for Selected product (Column Q = 17)
ActiveSheet.Range("$A$2:$AL2" & lastrow).AutoFilter Field:=17, Criteria1:=IFilterCell
Thanks for any help to get this working.
Robert