Just to let you know that i'm a quite a beginner when it comes to programming.
I've created a command button with the following code in the onclick event.
Private Sub Command125_Click()
Dim lst1 As ListBox, lst2 As ListBox
Dim itm As Variant
Set lst1 = Me!List123
Set lst2 = Me!List126
' Check selected items.
For Each itm In lst1.ItemsSelected
' Set RowSource property for first selected item.
If lst2.RowSource = "" Then
lst2.RowSource = lst1.ItemData(itm)
Else
' Check whether item has already been copied.
If Not InStr(lst2.RowSource, lst1.ItemData(itm)) > 0 Then
lst2.RowSource = lst2.RowSource & ";" & lst1.ItemData(itm)
End If
End If
Next itm
Dim lst1 As ListBox, lst2 As ListBox
Dim itm As Variant
Set lst1 = Me!List1
Set lst2 = Me!List2
' Check selected items.
For Each itm In lst1.ItemsSelected
' Set RowSource property for first selected item.
If lst2.RowSource = "" Then
lst2.RowSource = lst1.ItemData(itm)
lst1.RemoveItem itm
Else
' Check whether item has already been copied.
If Not InStr(lst2.RowSource, lst1.ItemData(itm)) > 0 Then
lst2.RowSource = lst2.RowSource & ";" & lst1.ItemData(itm)
lst1.RemoveItem itm
End If
End If
Next itm
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.