Hello,
I have userform that has 2 listbox's,
Listbox1 shows the data from search and by Adding command button i can select single row and transfer/move it to Listbox2
But for some reason everytime i transfer a new row from LB1 to LB2 the first one that i transfer is been overwritten by the later.
My code
I have userform that has 2 listbox's,
Listbox1 shows the data from search and by Adding command button i can select single row and transfer/move it to Listbox2
But for some reason everytime i transfer a new row from LB1 to LB2 the first one that i transfer is been overwritten by the later.
My code
VBA Code:
Private Sub CommandButton2_Click()
Dim i As Long
ReDim b(1, 1 To 16)
With ListBox2
.ColumnCount = 16
.List = b
.Clear
End With
For i = Me.ListBox1.ListCount - 1 To 0 Step -1
If Me.ListBox1.Selected(i) = True Then
Me.ListBox2.AddItem Me.ListBox1.List(i)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 1) = Me.ListBox1.List(i, 1)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 2) = Me.ListBox1.List(i, 2)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 3) = Me.ListBox1.List(i, 3)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 4) = Me.ListBox1.List(i, 4)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 5) = Me.ListBox1.List(i, 5)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 6) = Me.ListBox1.List(i, 6)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 7) = Me.ListBox1.List(i, 7)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 8) = Me.ListBox1.List(i, 8)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 9) = Me.ListBox1.List(i, 9)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 10) = Me.ListBox1.List(i, 10)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 11) = Me.ListBox1.List(i, 11)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 12) = Me.ListBox1.List(i, 12)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 13) = Me.ListBox1.List(i, 13)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 14) = Me.ListBox1.List(i, 14)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 15) = Me.ListBox1.List(i, 15)
Me.ListBox1.RemoveItem i
Exit For
End If
Next
End Sub