Private Sub UserForm_Initialize()
'alimente dynamiquement la ListBox1
Me.ListBox1.List = Application.Transpose(Range(Cells(1, 1), Cells(1, Application.Columns.Count).End(xlToLeft)))
End Sub
Private Sub CommandButton1_Click() 'bouton "Valider"
Dim i As Integer 'déclare la variable i (Incrémet)
For i = 0 To Me.ListBox1.ListCount - 1 'boucle sur tous les éléments de la ListBox1
'si l 'élément est sélectionner, affiche un message
If Me.ListBox1.Selected(i) = True Then MsgBox "L'élément " & Me.ListBox1.List(i) & " a été sélectionné."
Next i 'prochain élément de la boucle
Unload Me 'vide et ferme l'UserForm1
End Sub
Private Sub CommandButton2_Click() 'bouton 'Annuler"
Unload Me 'vide et ferme l'UserForm1
End Sub