[英]Can I change in Excel VBA combobox.list range?
Is there any option in Excel VBA which allows me to change range of combobox? Excel VBA 中是否有任何选项允许我更改 combobox 的范围? See example
查看示例
I would like to change number 5 in Variant/Variant(0 to 3, 0 to 5).我想更改 Variant/Variant 中的数字 5(0 到 3、0 到 5)。
Combobox is filled with this code: 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结束子
Try the next (adapted) code, please:请尝试下一个(改编的)代码:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.