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"