Private Sub UserForm_Initialize()
Dim iCtr As Range
Dim ws As Worksheet
Set ws = Worksheets("Additives")
For Each iCtr In ws.Range("IngID")
With Me.ListBox1
.AddItem iCtr.Offset(0, 1).Value
.List(.ListCount - 1, 1) = iCtr.Offset(0, 0).Value
End With
Next iCtr
Me.ListBox1.MultiSelect = fmMultiSelectMulti
Me.ListBox2.MultiSelect = fmMultiSelectMulti
End Sub
Private Sub BTN_moveAllLeft_Click()
Dim iCtr As Long
For iCtr = 0 To Me.ListBox2.ListCount - 1
With Me.ListBox1
.AddItem Me.ListBox2.List(iCtr)
.List(.ListCount - 1, 1) = Me.ListBox2.List(iCtr, 1)
End With
Next iCtr
Me.ListBox2.clear
End Sub
Private Sub BTN_MoveSelectedLeft_Click()
Dim ws As Worksheet
Dim iCtr As Long
Set ws = Worksheets("Additives")
For iCtr = 0 To Me.ListBox2.ListCount - 1
If Me.ListBox2.Selected(iCtr) = True Then
With Me.ListBox1
.AddItem Me.ListBox2.List(iCtr)
.List(.ListCount - 1, 1) = Me.ListBox2.List(iCtr, 1)
End With
End If
Next iCtr
For iCtr = Me.ListBox2.ListCount - 1 To 0 Step -1
If Me.ListBox2.Selected(iCtr) = True Then
Me.ListBox2.RemoveItem iCtr
End If
Next iCtr
End Sub
Private Sub BTN_moveAllRight_Click()
Dim iCtr As Long
For iCtr = 0 To Me.ListBox1.ListCount - 1
With Me.ListBox2
.AddItem Me.ListBox1.List(iCtr)
.List(.ListCount - 1, 1) = Me.ListBox1.List(iCtr, 1)
End With
Next iCtr
Me.ListBox1.clear
End Sub
Private Sub BTN_MoveSelectedRight_Click()
Dim ws As Worksheet
Dim iCtr As Long
Set ws = Worksheets("Additives")
For iCtr = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(iCtr) = True Then
With Me.ListBox2
.AddItem Me.ListBox1.List(iCtr)
.List(.ListCount - 1, 1) = Me.ListBox1.List(iCtr, 1)
End With
End If
Next iCtr
For iCtr = Me.ListBox1.ListCount - 1 To 0 Step -1
If Me.ListBox1.Selected(iCtr) = True Then
Me.ListBox1.RemoveItem iCtr
End If
Next iCtr
End Sub
Private Sub cmdOK_Click()
Unload Me
End Sub
Bookmarks