2016-11-29 33 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