Combobox filter the table - problem

thedogg

Board Regular
Joined
Sep 22, 2015
Messages
154
I have a problem if I want to filter the table in worksheet. I have 3 columns, supplier name, status and action. Here I am trying to change action (cmb change event). Sometimes it doesnt work for suppliers, sometimes I have one additional supplier on the list, sometimes some suppliers are missing. Could you please support?

Code:
Sub applyActionFilter()
Dim rCell As Range
Dim rngCMBSupplier As Range
Dim rngCMBAction As Range
Dim rngCMBStatus As Range
With Sheets("DETAIL INFORMATIONS")
    LastRow = .Cells(.Rows.Count, "X").End(xlUp).Row
End With
Set rngCMBSupplier = ActiveWorkbook.Worksheets("DETAIL INFORMATIONS").Range("AA2:AA" & LastRow)
Set rngCMBStatus = ActiveWorkbook.Worksheets("DETAIL INFORMATIONS").Range("AB2:AB" & LastRow)
Set rngCMBAction = ActiveWorkbook.Worksheets("DETAIL INFORMATIONS").Range("AC2:AC" & LastRow)
If V2_Report.CMB_Supplier.value = "" And V2_Report.CMB_Status.value = "" And V2_Report.CMB_Action.value <> "" Then
ActiveWorkbook.Worksheets("DETAIL INFORMATIONS").ListObjects("MainClipTable").Range.AutoFilter Field:=6, Criteria1:=V2_Report.CMB_Action.value
    With CreateObject("Scripting.Dictionary")
        For Each rCell In rngCMBSupplier
            If rCell.EntireRow.Hidden Then
            Else
                If Not .exists(rCell.value) And Not rCell.EntireRow.Hidden Then
                    .Add rCell.value, Nothing
                End If
            End If
        Next rCell
            V2_Report.CMB_Supplier.Clear
            V2_Report.CMB_Supplier.List = .keys
    End With
    
    With CreateObject("Scripting.Dictionary")
        For Each rCell In rngCMBStatus
            If rCell.EntireRow.Hidden Then
            Else
                If Not .exists(rCell.value) And Not rCell.EntireRow.Hidden Then
                    .Add rCell.value, Nothing
                End If
            End If
        Next rCell
            V2_Report.CMB_Status.Clear
            V2_Report.CMB_Status.List = .keys
    End With
    
    With CreateObject("Scripting.Dictionary") 'X
        For Each rCell In rngCMBAction
            If Not .exists(rCell.value) Then
                .Add rCell.value, Nothing
            Else
            End If
        Next rCell
            'V2_Report.CMB_Action.Clear
            V2_Report.CMB_Action.List = .keys
    End With
    
    


End If

End Sub

Code:
Set rngTable = ActiveWorkbook.Worksheets("DETAIL INFORMATIONS").Range("$X$1:$AE$" & LastRow)
Sheets("DETAIL INFORMATIONS").ListObjects.Add(xlSrcRange, rngTable, xlNo).name = _
        "MainClipTable"
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I think that another code is causing the problem. After I change combobox I am trying to update my Listbox1 with visible values only. It shows data only for fist hidden row.
Code:
Sub FilterListBoxH()
'last row
    Dim LastRow As Long
    With Sheets("DETAIL INFORMATIONS")
        LastRow = .Cells(.Rows.Count, "X").End(xlUp).Row
    End With
Dim rng As Range
Set rng = Sheets("DETAIL INFORMATIONS").Range("X2:AG" & LastRow).SpecialCells(xlCellTypeVisible)
'Set rng = rng.SpecialCells(xlCellTypeVisible)
rng.Select

    With V2_Report.ListBox1
        .BoundColumn = 1
        .ColumnCount = 8
        .ColumnHeads = False
        .TextColumn = True
        .ColumnWidths = "110;50;150;150;50;140;60;0"
        .List = rng.value
        .ListIndex = 0
    End With


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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