【发布时间】:2014-02-04 12:51:20
【问题描述】:
我有一个充满值的组合框。我想在组合框中选择一个值,然后单击“添加”按钮将此值放入下面的一些单元格中。我可以使用以下代码将一项添加到我的列表中,但我希望能够添加多项。我觉得我很接近,我只需要一些调整!
Private Sub CommandButtonAddItem_Click()
Dim ws As Worksheet
Dim box As ComboBox
Dim food As String
Dim num As Integer
num = 19
Set ws = Worksheets("sheet1")
Set box = ws.OLEObjects("ComboBox1").Object
food = box.Value
Worksheets("sheet1").Cells(num, 1) = food
If Worksheets("sheet1").Cells(num, 1) = " " Then
Worksheets("sheet1").Cells(num, 1) = food
num = num + 1
End If
End Sub
【问题讨论】: