Copier ma sélection dans un Label
Bonjour a toutes et tous, Forum bonjour
J'ai un USF1 avec une ListBox1 et un Label1
Une liste de nom sur ma Feuil1 baptiser (Compte) en colonne (T)
ListBox1 mis propriété sur Muliselect=1
Ma liste s'affiche bien dans le ListBox1 et je peux cocher plusieurs cases.
Je souhaiterai svp afficher (Le où les noms) sélectionnés dans le Label1
Malgré de multiples essais, je ni parviens pas.
Merci et bon début de semaine a tous
Cordialement Ray
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
Option Explicit
Private Sub UserForm_Initialize()
Dim I As Integer
ListBox1.Clear
For I = 1 To Sheets("Compte").[T50].End(xlUp).Row
If ListBox1.ListIndex = -1 Then
ListBox1.AddItem Sheets("Compte").Cells(I, "T")
End If
Next I
ListBox1.List() = Range("T1:T50").Value
End Sub
'*****
Private Sub ListBox1_Click()
Dim compt As Integer
For compt = 0 To (ListBox1.ListCount - 1)
If ListBox1.Selected(compt) = True Then
Label1.Caption = ListBox1.List(compt)
End If
Next compt
End Sub |