Bonjour,
Merci pour vos retour!!
Alors vous me précisez de mettre la ligne à 2 endroits :
Vous devez avoir cette ligne à deux endroits. Dans la sub initialize et à l'endroit de votre vue.
Sauf à dire que je perds totalement, je ne pense pas avoir de "SUB INITIALIZE" et c'est surement la mon problème...
Je vous transmet mon code global:
Private Sub Label11_Click()
End Sub
Private Sub UserForm_Initialize()
ComboBox1.List() = Array("M.", "Mme", "Mlle")
End Sub
Private Sub CommandButton1_Click()
If MsgBox("Confirmez-vous l'insertion de ce nouveau contact ?", vbYesNo + vbDefaultButton2, "Demande de confirmation d'ajout") = vbYes Then
If TextBox2.Text = vbNullString Then MsgBox "veuillez ajouter un nom de client !", vbCritical, "Client inconnu": Exit Sub
With Sheets("Clients").ListObjects(1)
If .ListRows.Count = 0 Then
.ListRows.Add: lig = 1
Else: .ListRows.Add: lig = .ListRows.Count
End If
With .DataBodyRange
.Item(lig, 1) = Label11.Caption
.Item(lig, 2) = ComboBox1.Text
.Item(lig, 3) = TextBox1.Text
.Item(lig, 4) = TextBox2.Text
.Item(lig, 5) = TextBox3.Text
.Item(lig, 6) = TextBox4.Text
.Item(lig, 7) = TextBox5.Text
.Item(lig, 8) = TextBox6.Text
.Item(lig, 9) = TextBox7.Text
End With
End With
End If
Call ViderUSF 'ou ViderUSF
Label11 = WorksheetFunction.Max(Sheets("Clients").ListObjects(1).ListColumns(1).DataBodyRange) + 1
End Sub
Private Sub CommandButton2_Click()
Dim Ligne As Long
Dim I As Integer
If MsgBox("Confirmez-vous la modification de ce contact ?", vbYesNo, "Demande de confirmation de modification") = vbYes Then
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
Ws.Cells(Ligne, "B") = ComboBox2
For I = 1 To 7
If Me.Controls("TextBox" & I).Visible = True Then
Ws.Cells(Ligne, I + 2) = Me.Controls("TextBox" & I)
End If
Next I
End If
End Sub
Private Sub CommandButton3_Click()
Unload Me
End Sub
Private Sub ViderUSF()
Dim c As Control
For Each c In Me.Controls
Select Case TypeName(c)
Case "TextBox"
c.Value = vbNullString
Case "ComboBox"
c.Value = vbNullString
c.ListIndex = -1
End Select
Next c
End Sub
Merci mille fois pour votre aide
Bien à vous