Private Sub ComboBox1_Change()
Dim Ligne&, i%
SelectedIndex = ComboBox1.ListIndex
If SelectedIndex = -1 Then
ComboBox2.ListIndex = -1
For i = 2 To 14: Controls("TextBox" & i) = "": Next i
Else
Ligne = ComboBox1.ListIndex + 2
ComboBox2 = Ws.Cells(Ligne, "B"): TextBox1 = Ws.Cells(Ligne, "C")
For i = 2 To 15
Controls("TextBox" & i) = Format(Ws.Cells(Ligne, i + 2), "0.00")
Next i
Ligne = Cells(Rows.Count, "P").End(3).Row: TextBox15 = Cells(Ligne, "P")
Cells(SelectedIndex + 2, 1).Select
End If
End Sub
Private Sub Valider_Click() 'sub du bouton Modifier
If TextBox1 = "" Then Exit Sub 'il faut qu'il y aie un nom !
Dim Ligne&, i%
If MsgBox("Êtes-vous certain de vouloir mofifier la fiche ?", vbYesNo, _
"Demande de confirmation") <> vbYes Then Exit Sub
If SelectedIndex = -1 Then Exit Sub
Ligne = SelectedIndex + 2
Ws.Cells(Ligne, "B") = ComboBox2
If TextBox1.Visible Then Ws.Cells(Ligne, 3) = TextBox1
For i = 2 To 13
With Controls("TextBox" & i)
If .Visible Then
If .Value <> "" Then Ws.Cells(Ligne, i + 2) = Val(Replace$(.Value, ",", "."))
End If
End With
Next i
TextBox14 = Ws.Cells(Ligne, "P"): Ligne = Cells(Rows.Count, "P").End(3).Row
TextBox15 = Cells(Ligne, "P")
End Sub