在 Excel VBA 中是否有任何选项允许我改变 combobox 的范围?请看示例
我想把VariantVariant(0到3,0到5)中的数字5改一下。
Combobox中填入了这段代码。
Private Sub UserForm_Activate()
Dim x As Range
With Worksheets("Distributori")
Set x = .Range("A2", .Range("F1000").End(xlUp))
End With
ComboBox1.RowSource = "Distributori!" & x.Address
ComboBox1.ListIndex = 0
Me.ComboBox1.TextColumn = 2
End Sub
请尝试下一个(改编)代码。
Dim x As Range, arrList As Variant
With Worksheets("Distributori")
Set x = .Range("A2", .Range("F1000").End(xlUp))
End With
arrList = x.Value
With ComboBox1
.ColumnCount = 6
.list = arrList
.ListIndex = 0
.TextColumn = 2
End With