Lire listbox

Bonjour

J'aurais voulu pouvoir lire un listbox qui contient plusieurs colonne donc pouvoir lire plusieurs "cellule" de la ligne selectionnée.

Merci d'avance a tous

Bonjour

a=listbox.list(ligne,colonne)

listbox est le nom de ta listbox

ligne et colonne commencent à 0

bon et bien j'ai bien fait alors mais il ne veut pas me le prendre qu'est ce qui cloche?

il me dit "erreur de variable, variable non définit"

Private Sub L_interventions_Click()
'déclaration des variables
Dim Com As String
Dim ligne As Long
Dim drlig As Integer
Dim i As Integer

Sheets("Intervention").Select
ligne = L_interventions.ListIndex
    If L_interventions.ListIndex <> -1 Then
        Range("A3").Select
        drlig = Sheets("Intervention").Range("a3").End(xlDown).Row

    For i = 0 To drlig
    If ActiveCell.Offset(i, 0).Value = L_interventions.list(ListIndex, 0) Then
    T_cominter = ActiveCell.Value

    End If
    Next i
    End If

End Sub

Bonjour,

je suppose que la variable T_cominter n'est pas définie

il s'agit d'un textbox que je rempli

J'ai essayer de modifier et reprendre le même code que toi mais pareil il me met en défaut listindex biensur il y a un dim a as string au dessus

For i = 0 To drlig
    a = L_interventions.list(ListIndex, 0)
    If ActiveCell.Offset(i, 0).Value = a Then
    T_cominter = ActiveCell.Value

re-bonjour,

mets-nous ton fichier

Bonjour voilà le fichier il faut aller dans l'onglet historique intervention faire un filtre quelconque et quand on clique sur une intervention on doit apercevoir le commentaire dans le textbox.

Et la il ne correspond pas

Merci

Bonjour,

proposition de correction

Private Sub L_interventions_Click()
'déclaration des variables
    Dim Com As String
    Dim ligne As Long
    Dim drlig As Integer
    Dim i As Integer
    Dim a As String

    ligne = L_interventions.ListIndex
    If L_interventions.ListIndex <> -1 Then
        drlig = Sheets("Intervention").Range("a3").End(xlDown).Row
        For i = 0 To drlig
            a = L_interventions.list(L_interventions.ListIndex, 0)
            If Sheets("intervention").Range("A3").Offset(i, 0).Value = a Then
                T_cominter = ActiveCell.Value
                Exit For
            End If
        Next i
    End If

End Sub

merci ca m'a mis sur la piste j'ai donc en fin de compte écrit ça

Private Sub L_interventions_Click()

    If L_interventions.ListIndex <> -1 Then
        T_cominter = L_interventions.list(L_interventions.ListIndex, 6)
    End If

End Sub

merci a toi

Rechercher des sujets similaires à "lire listbox"