![]() |
autofiltering using a dropdown list
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 |
autofiltering using a dropdown list
Gina Try Debra Dalgliesh's site www.contextures.com for excellent examples on filters Peter Atherton 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 |
autofiltering using a dropdown list
Thanks for this Peter
"PeterAtherton" wrote: Gina Try Debra Dalgliesh's site www.contextures.com for excellent examples on filters Peter Atherton 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 |
All times are GMT +1. The time now is 05:37 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com