Private Sub ComboBox1_Change()
Dim Col As Integer, DLig As Long, Lig As Long, Tot As Single
' Vider la Listbox des options et prix
Me.ListBox1.Clear
' Col = 1ère colonne trouvée de la marque + choix du modèle
Col = Application.WorksheetFunction.Match(Me.CbBMarques1, Sheets("Feuil1").Rows(1), 0)
Col = Col + Me.ComboBox1.ListIndex
' Si aucun choix fait dans le modèle, on sort
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
' Sinon on récupère les options
With Sheets("Feuil1")
'DLig = Range("U" & Rows.Count).End(xlUp).Rows
DLig = 72
Tot = 0
For Lig = 21 To DLig
If .Cells(Lig, Col).Value <> 0 Then
Me.ListBox1.AddItem .Range("C" & Lig)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Format(.Range("B" & Lig).Value, "0€")
Tot = Tot + CDec(.Range("B" & Lig))
End If
Next Lig
End With
Me.Label1.Caption = Format(Tot, "0€")
End Sub
Private Sub ComboBox2_Change()
Dim Col As Integer, DLig As Long, Lig As Long, Tot As Single
' Vider la Listbox des options et prix
Me.ListBox2.Clear
' Col = 1ère colonne trouvée de la marque + choix du modèle
Col = Application.WorksheetFunction.Match(Me.CbBMarques2, Sheets("Feuil1").Rows(1), 0)
Col = Col + Me.ComboBox2.ListIndex
' Si aucun choix fait dans le modèle, on sort
If Me.ComboBox2.ListIndex = -1 Then Exit Sub
' Sinon on récupère les options
With Sheets("Feuil1")
'DLig = .Range("I" & Rows.Count).End(xlUp).Rows
DLig = 72
Tot = 0
For Lig = 21 To DLig
If .Cells(Lig, Col).Value <> 0 Then
Me.ListBox2.AddItem .Range("C" & Lig)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 1) = Format(.Range("B" & Lig).Value, "0,00 €")
Tot = Tot + CDec(.Range("B" & Lig))
End If
Next Lig
End With
Me.Label2.Caption = Format(Tot, "0,00 €")
End Sub