All:
I have a listbox that is populated by a dynamic range from another sheet. The listbox has (1) command button. Once that command button is selected, it "grabs" the selected lines of record and adds them to a worksheet so those records can be assigned. Below is my code that I am working through:
End Sub
As it stands now, only the first selection I make out of the listbox is populating in the worksheet I want to "drop" the data in. Ideally, I want to drop all of the selected rows of data into the worksheet.
Any guidance on this one?
I have a listbox that is populated by a dynamic range from another sheet. The listbox has (1) command button. Once that command button is selected, it "grabs" the selected lines of record and adds them to a worksheet so those records can be assigned. Below is my code that I am working through:
Code:
Private Sub cmdAssign_Click()
Dim addme As Range
Dim x As Integer, Ck As Integer
Set addme = Sheet9.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
Ck = 0
'Run the loop
For x = 0 To listMulti.ListCount - 1
'Add conditional statement
If Me.listMulti.Selected(x) Then
Ck = 1
addme = Me.listMulti.List(x)
addme.Offset(0, 1) = Me.listMulti.List(x, 1)
addme.Offset(0, 2) = Me.listMulti.List(x, 2)
addme.Offset(0, 3) = Me.listMulti.List(x, 3)
addme.Offset(0, 4) = Me.listMulti.List(x, 4)
addme.Offset(0, 5) = Me.listMulti.List(x, 5)
addme.Offset(0, 6) = Me.listMulti.List(x, 8)
addme.Offset(0, 7) = Me.listMulti.List(x, 9)
addme.Offset(0, 8) = Me.listMulti.List(x, 12)
addme.Offset(0, 9) = Me.listMulti.List(x, 13)
addme.Offset(0, 10) = Me.listMulti.List(x, 14)
addme.Offset(0, 11) = Me.listMulti.List(x, 15)
addme.Offset(0, 12) = Me.listMulti.List(x, 16)
Set addme = addme.Offset(1, 0)
'Clear the selected values
listMulti.Selected(x) = False
End If
Next x
'Send a message if nothing is selected
If Ck = 0 Then
MsgBox "Nothing is selcted"
End If
As it stands now, only the first selection I make out of the listbox is populating in the worksheet I want to "drop" the data in. Ideally, I want to drop all of the selected rows of data into the worksheet.
Any guidance on this one?