Index choix dans listbox à choix multiples

  • Initiateur de la discussion Initiateur de la discussion decid
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

decid

XLDnaute Nouveau
Bonjour,

Je cherche à récupérer l'index des choix dans une listbox à choix multiple.

Ex Dans liste des mois de l'année :
Janvier Février Mars Avril Mai Juin Juillet Août Septembre Octobre Novembre Décembre

Je souhaite récupérer 3 pour Mars, 7 pour Juillet ...
La fonction listIndex en multicritère ne donne que le dernier No choisi.

Ci-joint fichier ex : NoChoixListBox.xlsm

Merci d'avance

Yves PETIT-PIERRE
 

Pièces jointes

Re : Index choix dans listbox à choix multiples

Bonjour decid

A tester:

Code:
Private Sub Ok_Valider_Click()
Dim ChoixList As String
Dim i As Byte
Dim NoChoixList As String
    ChoixList = ""
    With ListBoxSections
        For i = 0 To .ListCount - 1
            If .Selected(i) Then
                ChoixList = ChoixList & i + 1 & ";"
            End If
        Next
    End With
    ChoixList = Left(ChoixList, Len(ChoixList) - 1)
    Unload Me
End Sub
 
Re : Index choix dans listbox à choix multiples

Bonjour decid

A tester:

Code:
Private Sub Ok_Valider_Click()
Dim ChoixList As String
Dim i As Byte
Dim NoChoixList As String
    ChoixList = ""
    With ListBoxSections
        For i = 0 To .ListCount - 1
            If .Selected(i) Then
                ChoixList = ChoixList & i + 1 & ";"
            End If
        Next
    End With
    ChoixList = Left(ChoixList, Len(ChoixList) - 1)
    Unload Me
End Sub

Merci de votre aide et bonne journée, après réflexion , j'ai fait :

Code:
Private Sub Ok_Valider_Click()
Dim ChoixList As String
Dim i As Byte
Dim NoChoixList As String
    ChoixList = ""
    With ListBoxSections
        For i = 0 To .ListCount - 1
            If .Selected(i) Then
                ChoixList = ListBoxSections.List(i)
                NoChoixList = i + 1
                 Debug.Print NoChoixList
            End If
        Next
    End With
    Unload Me
End Sub
[/QUOTE]
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
9
Affichages
981
Réponses
11
Affichages
1 K
Retour