Can someone help me to fix my code to link 2 module ActiveX combo box to act as a filter based on another combo box, please?
In my test file, I want cboColor will show value based on selection on cboStyle.
Sub Continue()
Dim objDict As Object, db, xCell
Dim rng As Range
Dim ws As Worksheet
With Sheets("ProductMaster").ListObjects("ProductMaster").Range
.AutoFilter Field:=5
.AutoFilter Field:=4
.AutoFilter Field:=3
End With
Set ws = Worksheets("ProductMaster")
Set rng = ws.Range("C2:c" & ws.Cells(ws.Rows.Count, 1).End(xlUp).Row + 1)
Set objDict = CreateObject("Scripting.Dictionary")
objDict.CompareMode = vbTextCompare With Worksheets("ProductMaster")
For Each xCell In rng
If Not objDict.exists(xCell.Value) Then
objDict.Add xCell.Value, Nothing
End If
Next xCell
End With
Worksheets("Dashboard").cboStyle.List = objDict.Keys
objDict.RemoveAll
'Refresh Everything
ActiveWorkbook.RefreshAll End Sub
Display More
Private Sub cboStyle_Change()
Dim objDict As Object, db
Dim rngArea As Range, AreaItems, xCell
Set objDict = CreateObject("Scripting.Dictionary")
objDict.CompareMode = vbTextCompare
With Sheets("ProductMaster").ListObjects("ProductMaster").Range
.AutoFilter Field:=5
.AutoFilter Field:=4
.AutoFilter Field:=3, Criteria1:="=" & Worksheets("Dashboard").cboStyle.Value, Operator:=xlFilterValues
.AutoFilter Field:=2
.AutoFilter Field:=1
End With
On Error Resume Next ' Error Handler
Set rngArea = Worksheets("ProductMaster").Range("ProductMaster").Resize(, 5).SpecialCells(12)
On Error Resume Next ' Error Handler
For Each AreaItems In rngArea.Areas
db = AreaItems.Value
For xCell = LBound(db) To UBound(db)
If Not objDict.exists(db(xCell, 4)) Then
objDict.Add db(xCell, 4), Nothing
End If
Next
Next
On Error GoTo 0 ' Error Handler
End Sub
Display More