Private Sub ComboBox1_Change() Dim x% If Me.ComboBox1.Value = "张三" Then x = 13 Else x = 15 End If For y = 1 To x ComboBox2.AddItem Sheets("sheet1").Cells(y, 2) Next y End Sub
Private Sub UserForm_Initialize() Dim m%, n%, x%, y% With Sheets("sheet1") m = .Range("A65536").End(xlUp).Row For n = 1 To m ComboBox1.AddItem .Cells(n, 1) Next n End With End Sub
Private Sub ComboBox1_Change() Dim x% If Me.ComboBox1.Value = "张三" Then x = 13 Else x = 15 End If For y = 1 To x ComboBox2.AddItem Sheets("sheet1").Cells(y, 2) Next y End Sub
Private Sub UserForm_Initialize() Dim m%, n%, x%, y% With Sheets("sheet1") m = .Range("A65536").End(xlUp).Row For n = 1 To m ComboBox1.AddItem .Cells(n, 1) Next n End With End Sub
Private Sub ComboBox1_Click() Me.ComboBox2.Clear If Me.ComboBox1.Value = "张三" Then x = 12 Else x = 17 End If With Sheets("sheet1")
For y = 1 To x ComboBox2.AddItem .Cells(y, 2) Next y End With End Sub
Private Sub UserForm_Initialize() Dim m%, n%, x%, y% With Sheets("sheet1") m = .Range("A65536").End(xlUp).Row For n = 1 To m ComboBox1.AddItem .Cells(n, 1) Next n
Private Sub ComboBox1_Change() If ComboBox1.Value = "张三" Then ComboBox2.RowSource = "sheet1!b1:b12" Else ComboBox2.RowSource = "sheet1!b1:b15" End If End Sub Private Sub UserForm_Initialize() ComboBox1.RowSource = "sheet1!A1:A2" ComboBox2.RowSource = "sheet1!b1:b17" End Sub