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.
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