autofiltering using a dropdown list

G

Guest

Hi,

I am stuck on this problem, hopefully someone can help me. Basically what
I've got is a dropdown list of 3 options - A,B and C with a linking cell
which shows 1 if A is selected, 2 for B and 3 for c. In the cell next (F2)
to that I have a vlookup so that it shows what letter it corresponds to each
time a new option is selected. On another sheet I have a list of As Bs and
Cs which represent my records. What I am trying to do is when a letter is
selected this list is autofiltered based on what the vlookup cell shows. The
code I have is:

Sub filter()

If Worksheets("data").Range("E2").Value = "A" Then
Worksheets("data records").AutoFilter Field:=1, Criteria1:=Range("F2")

ElseIf Worksheets("data").Range("E2").Value = "2" Then
Worksheets("data records").AutoFilter Field:=1, Criteria1:=Range("F2")

Else
Worksheets("data records").AutoFilter Field:=1, Criteria1:=Range("F2")

End If

End Sub


The autofilter doesn't work. Can some tell me where I am goin wrong and
what the best way is to go about doing this.

Thanks
 

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

Top