Récupérer resultats Multiple Listbox au rappel d'un Userform

Hello,

J'utilise un Userform avec une listbox à choix multiples.

J'insere ensuite le resultat des selections du listbox dans une cellule séparés par un retour chariot chr(10)

Si je rappel mon Userform, je voudrais que dans ma listbox soit en surbrillance les elements présent dans la cellule préalablement remplie...

En gros recupérer l'ancien choix pour une modification...

Si quelqu'un veux bien m'expliquer comment faire

Merci bcp

Nico

Bonjour Nico,

Voici un exemple, il faudra modifier ActiveCell par la cellule de ton choix Range("A1") ou autre.

Private Sub CommandButton1_Click()
 For i = 0 To Me.ListBox1.ListCount - 1
   If Me.ListBox1.Selected(i) = True Then temp = temp & Me.ListBox1.List(i) & Chr(10)
 Next i
 ActiveCell = Trim(temp)  'à adapter
End Sub

Private Sub UserForm_Initialize()
Set Sh = Sheets("Feuil1")
With Me.ListBox1
.List = Range("plg").Value
.MultiSelect = fmMultiSelectMulti

    a = Split(ActiveCell, Chr(10))   'à adapter
    If UBound(a) >= 0 Then
      For i = 0 To Me.ListBox1.ListCount - 1
        If Not IsError(Application.Match(Me.ListBox1.List(i), a, 0)) Then Me.ListBox1.Selected(i) = True
      Next i
    End If

End With
End Sub

Simple rapide et efficace, comme toujours

Merci SabV !!!

Rechercher des sujets similaires à "recuperer resultats multiple listbox rappel userform"