librkvn
07-20-2013, 12:06 PM
I need help in converting the following code to work with a combobox instead of listbox. I may be working with a row source that is several thousand rows long and listbox it would be to cumbersome for the user to use a listbox in this case?
Private Sub cmdAdd_Click()
Dim iListCount As Integer
Dim iRow As Integer
Dim rStartCell As Range
Set rStartCell = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
For iListCount = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(iListCount) = True Then 'User has selected
ListBox1.Selected(iListCount) = False
iRow = iRow + 1
rStartCell.Cells(iRow, "A").Value = ListBox1.List(iListCount, 0)
rStartCell.Cells(iRow, "B").Value = ListBox1.List(iListCount, 1)
rStartCell.Cells(iRow, "D").Value = ListBox1.List(iListCount, 2)
End If
Next iListCount
Set rStartCell = Nothing
Unload Me
Range("C8").Select
End Sub
Private Sub cmdAdd_Click()
Dim iListCount As Integer
Dim iRow As Integer
Dim rStartCell As Range
Set rStartCell = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
For iListCount = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(iListCount) = True Then 'User has selected
ListBox1.Selected(iListCount) = False
iRow = iRow + 1
rStartCell.Cells(iRow, "A").Value = ListBox1.List(iListCount, 0)
rStartCell.Cells(iRow, "B").Value = ListBox1.List(iListCount, 1)
rStartCell.Cells(iRow, "D").Value = ListBox1.List(iListCount, 2)
End If
Next iListCount
Set rStartCell = Nothing
Unload Me
Range("C8").Select
End Sub