将此添加到您的用户表单代码中:
Private Sub UserForm_Initialize()
Dim rnLevel1 As Range, rnLevel2 As Range, rnTemp As Range
Set rnLevel1 = Sheet1.Cells(2, Sheet1.UsedRange.Columns.Count)
ComboBox2.Clear 'Clear all values first
For Each rnTemp In rnLevel1
If rnTemp.Value <> "" And rnTemp.Value <> "Level 1" Then ' Add values NOT INCLUDING Level 1 to Combobox1
ComboBox1.AddItem rnTemp.Value
End If
Next
End Sub
Private Sub ComboBox1_Change()
Dim rnLevel1 As Range, rnLevel2 As Range, rnTemp As Range
Set rnLevel1 = Sheet1.Cells(2, Sheet1.UsedRange.Columns.Count).Find(ComboBox1.Value) 'Find the correct column
Set rnLevel2 = Sheet1.Range(rnLevel1.Offset(1, 0), Sheet1.Cells(Sheet1.Rows.Count, rnLevel1.Column).End(xlUp))
ComboBox2.Clear 'Clear all values first
For Each rnTemp In rnLevel2
If rnTemp.Value <> "" Then ' Add values to Combobox2
ComboBox2.AddItem rnTemp.Value
End If
Next
End Sub