Public WithEvents bt As MSForms.CommandButton
Dim cls() As New UserForm1
Public u As Object
Private Sub bt_Click()
With bt
If .Tag = "" Then
u.ListBox1.AddItem bt.Caption: bt.Tag = u.ListBox1.ListCount - 1: .BackColor = &H8000000A
Else
With u.ListBox1
.Value = bt.Caption
.RemoveItem .ListIndex: bt.Tag = "": bt.BackColor = &H8000000F
.ListIndex = -1
End With
End If
End With
End Sub
Private Sub UserForm_Activate()
Dim ctrl, i&
For Each ctrl In Me.Controls
If ctrl.Tag = "-" Then
i = i + 1: ReDim Preserve cls(1 To i): Set cls(i).bt = ctrl: Set cls(i).u = Me: ctrl.Tag = ""
End If
Next
End Sub