Option Explicit
Dim Ws As Worksheet
Private Sub Enregistrer_Click()
End Sub
Private Sub commandbouton1click_Click()
End Sub
Private Sub Label16_Click()
End Sub
Private Sub Label4_Click()
End Sub
Private Sub TextBox7_Change()
End Sub
'Pour le formulaire
Private Sub UserForm_Initialize()
Dim J As Long
Dim I As Integer
ComboBox2.ColumnCount = 1 'Pour la liste déroulante Client
ComboBox2.List() = Array("toto1, toto2, toto3")
Set Ws = Sheets("Fichier Visite Client") 'Correspond au nom de votre onglet dans le fichier Excel
With Me.ComboBox1
For J = 2 To Ws.Range("A" & Rows.Count).End(xlUp).Row
.AddItem Ws.Range("A" & J)
Next J
End With
For I = 1 To 15
Me.Controls("TextBox" & I).Visible = True
Next I
End Sub
'Pour la liste déroulante Code client
Private Sub ComboBox1_Change()
Dim Ligne As Long
Dim I As Integer
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
ComboBox2 = Ws.Cells(Ligne, "A")
For I = 1 To 15
Me.Controls("TextBox" & I) = Ws.Cells(Ligne, I + 1)
Next I
End Sub
'Pour le bouton Nouveau contact
Private Sub CommandButton1_Click()
Dim L As Integer
Dim Chemin As String
If MsgBox("Confirmez-vous l'insertion de ce nouveau contact ?", vbYesNo, "Demande de confirmation d'ajout") = vbYes Then
L = Sheets("Rapport").Range("a65536").End(xlUp).Row + 0 'Pour placer le nouvel enregistrement à la première ligne de tableau non vide
Range("A" & L).Value = ComboBox1
Range("M" & L).Value = ComboBox2
Range("B" & L).Value = TextBox1
Range("C" & L).Value = TextBox2
Range("D" & L).Value = TextBox3
Range("E" & L).Value = TextBox4
Range("F" & L).Value = TextBox5
Range("G" & L).Value = TextBox6
Range("H" & L).Value = TextBox7
Range("I" & L).Value = TextBox8
Range("J" & L).Value = TextBox9
Range("K" & L).Value = TextBox10
Range("L" & L).Value = TextBox11
Range("M" & L).Value = TextBox12
Range("N" & L).Value = TextBox13
Range("O" & L).Value = TextBox14
Range("P" & L).Value = TextBox15
End If
Application.ScreenUpdating = False
Chemin = "C:\Monrépertoire\"
Sheets("Rapport").Copy
With ActiveWorkbook
' -> a corriger par la valeur de la combobox1'.SaveAs Filename:=Chemin & ThisWorkbook.Sheets("Rapport").Range("A1") & " " & Format(Now, "yy-mm-dd hhmmss")
.Close
End With
End Sub
'Pour le bouton Quitter
Private Sub CommandButton2_Click()
Unload Me
End Sub