Filter column based on word chosen from a seperate drop down list

Jeffington

New Member
Joined
Mar 22, 2006
Messages
4
Hi,

I have a drop down list populated with words such as 'Urgent', 'High', 'Medium' etc. I want to be able to choose one of these from a drop down list, then have a macro mapped to a button (I can do that bit) that then filters another column for that chosen word. I've started with Urgent to see if I can get this to work, but I can't even do that. Can anyone help?

Sub Test_Sort_Priority()
'
' Test_Sort_Priority Macro
'

'
Range("G8").Select
If cell.Value = "Urgent" Then
ActiveSheet.Range("$B$13:$P$23").AutoFilter Field:=2, Criteria1:="Urgent"
End If
End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You could use a Worksheet_Change event to reset the filter automatically. Provide a sample of your sheet using the XL2BB Tool and I'll be happy to show you how.
 
Upvote 0
The following code is based on G8 being your data validation cell, with your data starting in row 14 (row 13 being headers). You put this code in the sheet code area of the sheet of interest (right-click the sheet tab; select view code - the window that appears is where this code goes, on the right). Save the file & test it. When you make a new selection in G8, your data should be automatically filtered according to your data validation choice.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Range("G8"), Target) Is Nothing Then
    Dim s As String: s = Range("G8")
        If s <> "" Then
            With Range("B13:P13")
                .AutoFilter 2, s
            End With
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,264
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top