• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to Create Dependent Activex Dropdown Box for dynamic range

Nitesh Khot

Member
Hi...

I want to know about how to create Dependent active-x dropdown box for dynamic range..

Thanks,
nitesh
 

Attachments

  • ABCD.xlsx
    16.2 KB · Views: 3
Thanks for reply...

I am looking for Dependent Active-X combobox...for worksheet to change pivot table or filter worksheet using Active-x Combobox
 
1) To ThisWorkbook code module
Code:
Option Explicit
Private Sub Workbook_Open()
    If ActiveSheet Is Sheets("sheet1") Then
        Run Sheets("sheet1").CodeName & ".worksheet_activate"
    End If
End Sub
2) To Sheet1 code module
Code:
Option Explicit
Private dic As Object

Private Sub Worksheet_Activate()
    Dim a, i As Long
    Set dic = CreateObject("Scripting.Dictionary")
    dic.CompareMode = 1
    a = [d1].CurrentRegion.Value
    For i = 2 To UBound(a, 1)
        a(i, 1) = CStr(a(i, 1)): a(i, 2) = CStr(a(i, 2))
        If Not dic.exists(a(i, 1)) Then
            Set dic(a(i, 1)) = CreateObject("Scripting.Dictionary")
            dic(a(i, 1)).CompareMode = 1
        End If
        dic(a(i, 1))(a(i, 2)) = Empty
    Next
    Me.ComboBox1.List = dic.keys
End Sub

Private Sub ComboBox1_Change()
    Me.ComboBox2.Clear
    If Me.ComboBox1.ListIndex > -1 Then Me.ComboBox2.List = dic(Me.ComboBox1.Value).keys
End Sub
 

Attachments

  • ABCD with oode.xlsm
    29.3 KB · Views: 11
Back
Top