Dynamic multilevel drop down list

slayer1957

Board Regular
Joined
Jan 9, 2017
Messages
50
Good day, I have a userform with 4x comboboxes,
First box, Equipment type
Second box, Unit
Third box, Equipment number
Fourth box, Spares selection

List should be dynamic, Equipment types, VSD, UPS, Battery Charger and be able to add more in first column of the sheet
List should be dynamic, 1,2,3,4,5 and be able to add more in second column of the sheet
Third box should filter according to the equipment number. It must check the corresponding column heading for instance VSD list, 1-VSD1,2-VSD2,3-VSD3 and filter according to the Unit number and display only the equipment VSDs in the corresponding unit
Fourth box should show the spares list, Driver board, Electronic main board etc. allocated to the selected VSD equipment number in the unit.

All lists must be dynamic

VBA Code:
Option Explicit

Private Sub ComboBox3_Change()

End Sub

Private Sub UserForm_Activate()

Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Combobox")
Dim i As Integer

Me.ComboBox1.Clear

For i = 1 To Application.CountA(sh.Range("1:1"))
    Me.ComboBox1.AddItem sh.Cells(1, i).Value
Next i

End Sub
Private Sub ComboBox1_Change()

Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Combobox")

Dim i, n As Integer
Me.ComboBox2.Clear

n = Application.WorksheetFunction.Match(Me.ComboBox1.Value, sh.Range("1:1"), 0)

For i = 2 To Application.WorksheetFunction.CountA(sh.Cells(1, n).EntireColumn)
    Me.ComboBox2.AddItem sh.Cells(i, n).Value

Next i

Me.ComboBox2.ListRows = 20


End Sub
Private Sub ComboBox2_Change()


Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Combobox")

Dim i, n As Integer
Me.ComboBox3.Clear

n = Application.WorksheetFunction.Match(Me.ComboBox1.Value, sh.Range("1:2"), 0)

For i = 3 To Application.WorksheetFunction.CountA(sh.Cells(1, n).EntireColumn)
    Me.ComboBox3.AddItem sh.Cells(i, n).Value

Next i

Me.ComboBox3.ListRows = 20

End Sub

This is what i got from another source, Dynamic mutli level drop down but it i do not know coding well. Could someone please assist.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I have my list options in their own sheet, then get all items with UsedRange:

Code:
Private Sub UserForm_Initialize()
Dim rng As Range
Sheets("Tables").Select
Range("a2").Select
Set rng = ActiveSheet.UsedRange
ListBox1.List = rng.Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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