VBA:将WS Range的值连接到ComboBox

时间:2016-11-29 17:50:27

标签: excel excel-vba vba

在我的电子表格中,我想要在ComboBox中显示大小的范围。

在Rage C43:c47中,我的值为100,200,300

在范围D43:D47中,我有一个X.

在范围E43:E47中,我的值为1000,1100,1200

我希望连接值,使其显示在ComboBox中,如100X1000200X1100300X1200

我该怎么做?

这是我使用的代码,当然它只显示一个Range

Me.SizeBox.List = Worksheets(1).Range("C43:C47").Value

1 个答案:

答案 0 :(得分:1)

试试这个

Sub stitute()
Dim row As Long
Dim lastrow As Long
lastrow = 3 'row that it finishes
col1 = 1 'Column with the first data
col2 = 2 'Column with the second data
col3 = 3 'Column with the third data

For row = 1 To lastrow 'Change the number to the starting row
    Me.SizeBox.AddItem Cells(row, col1).Value & Cells(row, col2).Value & Cells(row, col3).Value
Next row

End Sub
相关问题