How to create selection dependant comboboxs and define data source

tynawg

New Member
Joined
Oct 11, 2019
Messages
42
Hello,
A forum contributer helped me create a dynamic array for 2 comboboxs which works great.
Now I would like to understand how to either create a third combobox or set of third comboboxs based on the selection in box 2?
Presently the first row of all columns is the title with the data below in each column the selection available to populate combobox 2. Once a selection is made in box 2 i want to have displayed a unit of measure, description of box 2 selection etc etc.
Below is the code to date,
If anyone can point me in the right direction it will be much appreciated.
Code:
Dim arr() As Variant
Private Sub ComboBox1_Change()
    Dim Index As Integer
    Index = Me.ComboBox1.ListIndex
     With Me.ComboBox2
      If Index = -1 Then .RowSource = "": Exit Sub
        .RowSource = arr(Index + 1)
    End With
End Sub


Private Sub UserForm_Initialize()
    Dim lastrow As Long, lastcolumn As Long
    Dim i As Long
    Dim ws As Worksheet
    
    Set ws = Worksheets("Sheet1")
    
    lastcolumn = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
    ReDim arr(1 To lastcolumn)
        
    For i = 1 To lastcolumn
        lastrow = ws.Cells(ws.Rows.Count, i).End(xlUp).Row
        ws.Cells(1, i).Resize(lastrow).CreateNames Top:=True
        arr(i) = ws.Cells(1, i).Text
    Next i
        
    With Me.ComboBox1
        .RowSource = ""
        .List = arr
    End With
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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