Bonsoir Drosophile, bonsoir le forum,
Une autre méthode au double-clic. Quand on renvoie de la Listbox2 vers la ListBox1, les données ne sont plus triées comme initialement mais on peu y arriver si nécessaire.
Le code :
Option Explicit
Private Sub UserForm_Initialize()
Dim OT As Worksheet
Dim DC As Integer
Me.StartUpPosition = 0
Me.Top = 155
Me.Left = 150
Set OT = ActiveSheet
DC = OT.Cells(1, Application.Columns.Count).End(xlToLeft).Column
Me.ListBox1.Column = OT.Range(OT.Cells(1, 2), OT.Cells(2, DC)).Value
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim I As Integer
With Me.ListBox1
For I = .ListCount - 1 To 0 Step -1
If .Selected(I) = True Then
Me.ListBox2.AddItem .List(I)
.RemoveItem (I)
End If
Next I
End With
End Sub
Private Sub ListBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim I As Integer
With Me.ListBox2
For I = .ListCount - 1 To 0 Step -1
If .Selected(I) = True Then
Me.ListBox1.AddItem .List(I)
.RemoveItem (I)
End If
Next I
End With
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub