Hello,I have two listboxs in one userform,what i was trying to achieve is to move the row ive selected from Listbox1 to listbox2 which it works, problem is it only copies the first column of the data.
I have a total of 16 columns in my worksheet from B to Q. And the listbox1 only shows 4 columns of the data which is what i wanted to(minimized the data information).But when si run the code of moving from one listbox to another it only shows the first column of data ,what am i missing?
I have two command button to move around the data from listbox1 to listbox2 and vice versa.
Code from Listbox1 to ListBox2
Code for listbox 2 to listbox 1(return of data)
I have a total of 16 columns in my worksheet from B to Q. And the listbox1 only shows 4 columns of the data which is what i wanted to(minimized the data information).But when si run the code of moving from one listbox to another it only shows the first column of data ,what am i missing?
I have two command button to move around the data from listbox1 to listbox2 and vice versa.
Code from Listbox1 to ListBox2
VBA Code:
Private Sub CommandButton2_Click()
Dim i As Long
For i = Me.ListBox1.ListCount - 1 To 0 Step -1
If Me.ListBox1.Selected(i) = True Then
Me.ListBox3.AddItem Me.ListBox1.List(i)
Me.ListBox1.RemoveItem i
Exit For
End If
Next
End Sub
Code for listbox 2 to listbox 1(return of data)
VBA Code:
Private Sub CommandButton3_Click()
Dim i As Long
For i = Me.ListBox3.ListCount - 1 To 0 Step -1
If Me.ListBox3.Selected(i) = True Then
Me.ListBox1.AddItem Me.ListBox3.List(i)
Me.ListBox3.RemoveItem i
Exit For
End If
Next
End Sub