Back to Browse

Excel VBA Combo Boxes Dependency used dynamically in USERFORM (Tutorial)

14.1K views
Dec 1, 2016
19:30

Please subscribe to my channel For MORE FREE Tutorials. Creating Dependent Combo Boxes in Excel with standard User Form function using VBA coding to dynamically populate combo boxes (Tutorial) SEE CODE FOR COPYING AND PASTING BELOW: Email me if you would like the code. USE LINE OF CODE: Option Explicit Private Sub ComboBox1_Change() Dim index As Integer 'list combobox 1 and look for dependency index = ComboBox1.ListIndex ComboBox2.Clear 'find value Select Case index 'manual input Case Is = 0 With ComboBox2 .AddItem "Food" .AddItem "Pride" .AddItem "Harry" End With Case Is = 1 'Call content in range C dynamically With Worksheets("sheet1") ComboBox2.List = .Range("c2:c" & .Range("c" & Rows.Count).End(xlUp).Row).Value End With End Select End Sub Private Sub CommandButton1_Click() 'populate range A1 in sheets 1 Range("A1").Value = ComboBox2.Value End Sub Private Sub userform_initialize() 'dynamically call combobox1 when form initialize 'please keep line of code for credit. hall written 2016 With Worksheets("sheet1") ComboBox1.List = .Range("b2:b" & .Range("b" & .Rows.Count).End(xlUp).Row).Value End With End Sub

Download

0 formats

No download links available.

Excel VBA Combo Boxes Dependency used dynamically in USERFORM (Tutorial) | NatokHD