Bonsoir,
la lecture de la valeur de la combobox1 déclenche la sub Change de ce combobox, hors cette dernière permet de remplir les différent contrôles avec les données de la feuille, du coup le nom modifié du client est "re modifié" avec l'ancien... Rien a changé !
Une variable booléenne EnCours permet de sortir du Change du combobox prématurément et alors là les données ne sont plus modifiées et les nouvelles valeurs sont prises en compte.
Le début du code de votre USF :
Dim EnCours As Boolean
Private Sub ComboBox1_Change()
If EnCours Then Exit Sub
Set ws = Sheets("client")
Dim ligne As Long
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
ligne = Me.ComboBox1.ListIndex + 6
Me.cbx_civilite = ws.Cells(ligne, "C")
Me.txt_nom = ws.Cells(ligne, "D")
Me.txt_prénom = ws.Cells(ligne, "E")
Me.txt_nom_entreprise = ws.Cells(ligne, "F")
Me.txt_adresse = ws.Cells(ligne, "G")
Me.txt_cp = ws.Cells(ligne, "H")
Me.txt_ville = ws.Cells(ligne, "I")
Me.txt_tel = ws.Cells(ligne, "J")
Me.txt_mail = ws.Cells(ligne, "K")
Me.label_type = ws.Cells(ligne, "L")
If Me.label_type = "Pro" Then
Me.option_pro = True
Else
Me.option_prive = True
End If
End Sub
Private Sub CommandButton1_Click()
'Dim DL As Integer
Dim ligne As Long
'Sheets("client").ListObjects(1).ListRows.Add
'DL = Sheets("client").Range("B9999").End(xlUp).Row
ligne = Me.ComboBox1.ListIndex + 6
'Ajouter dans le tableau
EnCours = True
Sheets("client").Cells(ligne, "B") = Me.ComboBox1
Sheets("client").Cells(ligne, "C") = Me.cbx_civilite
Sheets("client").Cells(ligne, "D") = Me.txt_nom
Sheets("client").Cells(ligne, "E") = Me.txt_prénom
Sheets("client").Cells(ligne, "F") = Me.txt_nom_entreprise
Sheets("client").Cells(ligne, "G") = Me.txt_adresse
Sheets("client").Cells(ligne, "H") = Me.txt_cp
Sheets("client").Cells(ligne, "I") = Me.txt_ville
Sheets("client").Cells(ligne, "J") = Me.txt_tel
Sheets("client").Cells(ligne, "K") = Me.txt_mail
Sheets("client").Cells(ligne, "L") = Me.label_type
EnCours = False
ThisWorkbook.Save
Unload Me
End Sub
@ bientôt
LouReeD