Filter Sheet From Drop Down combo box.

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
Hi Anyone,

I've assigned a drop down combo box where I'm trying to filter the sheet when a text is selected from the drop down box.

The validation list that I'm using is =StaffList!$I$1:$I$12 where its name is MyList.

Following is the current code that I'm using.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Not Intersect(Range("E2"), Target) Is Nothing Then
      Application.EnableEvents = False
        Range("C10").CurrentRegion.AdvancedFilter _
          Action:=xlFilterInPlace, CriteriaRange:= _
          Range("N1:N2"), Unique:=False
      Application.EnableEvents = True
  End If
End Sub
The above code works fine when I use a data validation list in cell E2.

What I'm trying to do is to filter the sheet from the Drop Down Combo box when a text from the list is selected.

The cell link that I'm using is E2.

I hope I have made my question clear.

Any help on this would be kindly appreciated.
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,271
There are two types of combo-boxes besides the data validation drop-down list. How you would initiate your filter code would depend on the type of combobox you are using.

Form Control Combo Box Type:
  • Put your macro MyFilter in a standard module
  • Right-click on the Combobox and select Assign Macro
  • Assign the macro MyFilter (below)
Code:
Sub MyFilter()
    Application.ScreenUpdating = False
    Application.EnableEvents = False
        Range("C10").CurrentRegion.AdvancedFilter _
                     Action:=xlFilterInPlace, CriteriaRange:= _
                     Range("N1:N2"), Unique:=False
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub

ActiveX Combo Box Type:
In the sheet module, replace your existing Private Sub Worksheet_Change(ByVal Target As Range) code with this...
Code:
Private Sub ComboBox1_Change()
    Application.ScreenUpdating = False
    Application.EnableEvents = False
        Range("C10").CurrentRegion.AdvancedFilter _
                     Action:=xlFilterInPlace, CriteriaRange:= _
                     Range("N1:N2"), Unique:=False
    Application.EnableEvents = True
    Application.ScreenUpdating = False
End Sub
 

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
Thank you for your valuable information and help, AlphaFrog. The code now works the way as I had requested.

Once again thanks for the help & I do really appreciate your help.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,105,996
Messages
5,508,645
Members
408,689
Latest member
SamSan78

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top