Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50057

Combobox two options not filtering as expected

$
0
0
Please see my sheet attached. When I click on Filter Source (B14 roughly) I want to be able to select from the dropdown for Source and a dropdown for Status , as I have it set up at the moment.

but when hitting "Filter" button the filter doesnt work....what is wrong with my code?

Secondly (and this is a "like to have") - my second dropdown is limited to one item only (ie either WIP or NTU etc) - is it possible to lump them into two groups, one being "Live" which is "WIP", "Quoted" and "Bound" and the others in "Dead." So that my second dropdown only has two options, Live and Dead.

Activity London bak.xlsm

Code:

Sub Filter_Me()
   
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    With ActiveSheet
        If .FilterMode Then .showalldata
        .AutoFilterMode = False
        If Not OperatingDivision.ComboBox1.Value = "All" Then
            .Range("B16:B189").AutoFilter Field:=1, Criteria1:=OperatingDivision.ComboBox1.Value, _
                                        Operator:=xlOr, Criteria2:="=", Visibledropdown:=False
                                       
                                       
            .Range("I16:I189").AutoFilter Field:=1, Criteria1:=OperatingDivision.ComboBox2.Value, _
                                        Operator:=xlOr, Criteria2:="=", Visibledropdown:=False
    .Range("A17").EntireRow.Hidden = True
        Else
            .Range("A17").EntireRow.Hidden = True
        End If
    End With
 
   
    Call HideRows
   
       
    Application.ScreenUpdating = False
    Application.EnableEvents = True
 
End Sub

My userform is like this:

Code:

Private Sub UserForm_Initialize()
    Dim Source As Variant
    Dim Status As Variant
    Dim i As Long
    Dim k As Long
    Source = Array("All", "Company", "Syndicate", "EU Corporate")
    Status = Array("All", "WIP", "Quoted", "Bound", "NTU", "Modelling", "Declined", "Non-Renewed", "Extended")
    For i = LBound(Source) To UBound(Source)
        Me.ComboBox1.AddItem Source(i)
    Next i
    For k = LBound(Status) To UBound(Status)
        Me.ComboBox2.AddItem Status(k)
    Next k
End Sub


Viewing all articles
Browse latest Browse all 50057

Trending Articles