Sub CommandButton1_Click()
Dim Nom As String, nFich As String, Chemin As String, n As Integer
If TextBox1 = "" Then
MsgBox "Merci de renseigner le nom de la personne", vbOKOnly, "Erreur"
Else: Sheets("vierge").Visible = True
Worksheets("Vierge").Copy after:=Worksheets("Vierge")
Nom = TextBox1 & " " & TextBox2
ActiveSheet.Name = Nom
Cells(1, 2).Value = TextBox1
Cells(1, 3).Value = TextBox2
Cells(5, 2).Value = TextBox3
Cells(6, 2).Value = TextBox4
Cells(9, 2).Value = TextBox5
Cells(10, 2).Value = TextBox6
Cells(11, 2).Value = TextBox9
Cells(12, 5).Value = TextBox8
Cells(12, 7).Value = TextBox10
Cells(13, 3).Value = TextBox7
Unload UserForm1
Sheets("vierge").Visible = False
End If
ActiveSheet.Copy
Chemin = "S:\Dossier_Gestion\Gestion Ressources Humaines\Contrats de travail\Contrat\Fiches financières\"
n = 0
fichier = Nom & ".xlsx"
fichier1 = Nom & "V*.xlsx"
If Dir(Chemin & fichier) = "" And Dir(Chemin & fichier1) = "" Then ActiveWorkbook.SaveAs (Chemin & fichier): Exit Sub
nFich = Dir(Chemin & fichier1)
Do While nFich <> ""
n = Application.Max(n, Val(Split(Split(nFich, "V")(1), ".")(0)))
nFich = Dir
Loop
Nom2 = Nom & n + 1 & ".xlsx"
ActiveWorkbook.SaveAs (Chemin & Nom2) 'l'erreur vient ici!!!
End Sub