2016-11-29 53 views
-1

在我的电子表格中,我想要在ComboBox中显示大小的范围。VBA:连接WS Range到ComboBox的值

愤怒C43:c47我有一个像100,200,300

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

在范围E43:E47我有一个像1000,1100,1200

值我想连接的值出现在组合框中,如100X1000,200X1100300X1200

如何我可以那样做吗?

这是我使用的代码,但当然这只能说明一个Range

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

+1

是否必须在VBA?你可以在F43等中使用'= C43&D43&E43'吗? – bobajob

+0

@Alec是一个User_Form'ComboBox'或'ActiveX'?是'ComboBox'“SizeBox”的名字? –

+0

它必须是ActiveX,它会出现在UserForm – Alec

回答

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 
+0

完美,正是我想要做的。谢谢! – Alec

+0

欢迎您:) – Moacir