Private Sub CommandButton1_Click()
Dim Nomfeuille As String, Entree As String
Dim f As Worksheet 'déclare la variable f
Début:
Entree = TextBox1
For Each f In Sheets
If UCase(f.Name) = UCase(Entree) Or UCase(f.Name) = Entree Then _
' UCase(Left(Entree, 2) & "." & Mid(Entree, 3, 2) & "." & Right(Entree, 2)) Then 'accepte les MAJUSCULES/minuscules comme identiques
MsgBox "Ce Rapport Journalier Existe deja Veuillez recommencez l'operation sous un nom different Merci "
Exit Sub
GoTo Début:
End If
Next f
If Len(Entree) = 10 Then
Nomfeuille = Entree 'Left(Entree, 2) & "." & Mid(Entree, 3, 2) & "." & Right(Entree, 2)
'If Nomfeuille <>
Sheets("Base").Copy Before:=Worksheets(1) 'ou after:=Worksheets(Worksheets.count)
ActiveSheet.Name = Nomfeuille
Msg = "Votre Feuille heures a été sauvegardé sous le nom que lui avez donnez."
Title = "Sauvegarde du rapport journalier"
Style = vbOKOnly + vbInformation
Reponse = MsgBox(Msg, Style, Title)
End If
Sheets("Base").Copy
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & TextBox1.Value & ".xls"
Unload Me
End Sub