Combobox.value error 13 [RESOLU]

herve62

XLDnaute Barbatruc
Supporter XLD
Bonjour
Encore un truc tout bête je pense mais c'est toujours comme ça
J'ai repris une sub qui tourne dans un autre prog j'ai fait du copier/coller pour le code
et changé le nom de mes objets et là ça plante sur L= CB1.value ,
normalement si je choisis "batiment2" > L=5 ?
mais là erreur 13
 

Pièces jointes

  • testlist.xlsm
    18.9 KB · Affichages: 38

herve62

XLDnaute Barbatruc
Supporter XLD
Non , déjà le Me ne fait rien sinon le code était :
Code:
Private Sub cboFamille_Change()

    Dim Plage As Range
    Dim i As Long
    Dim Lmax As Long
    Dim L As Long

    If cboFamille.ListIndex >= 0 Then

        L = cboFamille.Value

        With Sheets("Produits")

            Lmax = .Cells(L, 2).End(xlDown).Row
            If Lmax = .Cells(L, 1).End(xlDown).Row Then Lmax = L
            Set Plage = .Range(.Cells(L, 2), .Cells(Lmax, 4))

        End With
 

herve62

XLDnaute Barbatruc
Supporter XLD
Dim L As Long et L = cboFamille.Value c'est incohérent.
Car, un pas-à-pas (F8) sur ma machine donne la valeur à L "Batiment x"
Alors pourquoi moi j'ai comme sur les images sachant que le 63 provient de mon choix Jardin dans la box( captures faites dans le fichier qui fonctionne bien sûr !!!)
??? qui s'initialise dans la sub avec le With CB1 et la "plage" juste définie avant
 

Pièces jointes

  • cb1.jpg
    cb1.jpg
    40.1 KB · Affichages: 22
  • prod.jpg
    prod.jpg
    9 KB · Affichages: 29

ChTi160

XLDnaute Barbatruc
Bonsoir
Bonsoir le Fil ,Le Forum
Voilà ce que j'ai modifie dans la procédure .
VB:
Private Sub CB1_Change()
    Dim Plage As Range
    Dim i As Long
    Dim Lmax As Long
    Dim L As Long
With CB1
   If .ListIndex >= 0 Then
    L = .List(.ListIndex, 1) 'On récupére la Ligne source
    Else
      Exit Sub 'On quitte
   End If
End With
        With Sheets("base")
            Lmax = .Cells(L, 2).End(xlDown).Row
            If Lmax = .Cells(L, 1).End(xlDown).Row Then Lmax = L
            Set Plage = .Range(.Cells(L, 2), .Cells(Lmax, 4))
        End With
        With LB1
            .Clear
            'une boucle afin de pouvoir mettre les quantités à 0
            For i = 1 To Plage.Rows.Count
                .AddItem    ' Plage(i, 1).Value
                .List(.ListCount - 1, 0) = Plage(i, 1).Value
                .List(.ListCount - 1, 1) = Plage(i, 2).Value
                .List(.ListCount - 1, 2) = Plage(i, 3).Value
                .List(.ListCount - 1, 3) = 0    'Plage(i, 4).Value
                .List(.ListCount - 1, 4) = 0
            Next i
        End With
End Sub
Bonne fin de Soirée
Amicalement
jean marie
 

herve62

XLDnaute Barbatruc
Supporter XLD
Bonsoir
J'aimerai bien comprendre la différence donc je mets le fichier d'origine d'ou j'ai recopié le code
Mettez un point d'arrêt à L= Cbofamille.value et vous verrez que selon le choix de la combo cela renvoie bien le N° de ligne
Pourquoi ce prog fonctionne et pas besoin de modif comme le préconise CHTI
 

Pièces jointes

  • Devis_V3.xlsm
    75 KB · Affichages: 28

ChTi160

XLDnaute Barbatruc
Re
j'ai cherché un peu et je me suis rappelé que l'on peut référencer la colonne a prendre en Compte à renvoyer.
Propriété "BoundColumn" du Control ComboBox .
1 tu Renvoies la colonne Texte et 2 la Colonne des Lignes .
ton ComboBox était sur "BoundColumn" = 2
Bonne fin de Soirée
Amicalement
jean marie
 

Discussions similaires

Statistiques des forums

Discussions
312 196
Messages
2 086 098
Membres
103 116
dernier inscrit
kutobi87