rodrigocf
rodrigocf

Reputation: 2099

Filter a table in VBA using a cell as criteria

I know that the solution for this might be very easy, but i'm a little lost.

I just need to make a statement that if Item to search (which is a cell), is equal to a text, either Cust_ID or ASIN, to filter a table called table (Table1) in field 5, for the cell in range F5, this is what i have and i don't know what's wrong.

This is what I have:

Sub Search_in_table()

Sheets("ADD INFO").Select

If Item_to_search = "Cust_ID" Then 
    Sheets("INFO").Select
    ActiveSheet.Range(Table1).AutoFilter Field:=5, Criteria1:=Range(F5), Operator:=xlFilterValues

End If

End Sub

Any ideas would be appreciated.

Upvotes: 0

Views: 4404

Answers (2)

LS_ᴅᴇᴠ
LS_ᴅᴇᴠ

Reputation: 11191

Hum... What you're asking isn't

If Item_to_search = "Cust_ID" Or Item_to_search = "ASIN" Then 

???

Upvotes: 0

Robert Co
Robert Co

Reputation: 1715

ActiveSheet.Range(Table1).AutoFilter Field:=5, Criteria1:=Range(F5)**.value**, Operator:=xlFilterValues

Upvotes: 1

Related Questions