Private Sub NewPage_Click()
' Creation page
Application.ScreenUpdating = False
Dim nomNewWS As String
Dim trouveWS As Boolean
Application.ScreenUpdating = False
Sheets("page source").Select
' Nom de la nouvelle feuille (dans la page source cellule B1 est inscrit la date a creer)
nomNewWS = Application.WorksheetFunction.Proper(Format(Range("B1").Value, "mmmm yyyy"))
' Vérifier que la feuille n'existe pas déjà
trouveWS = VerifFeuille(nomNewWS)
' Si la feuille existe déjà, ne rien faire
If trouveWS = True Then
MsgBox ("La page " & nomNewWS & " Existe déja!!"), vbExclamation, "Attention !"
End If
If trouveWS = True Then Exit Sub
' Ajouter une feuille dans le classeur
ActiveSheet.Copy after:=Worksheets(ThisWorkbook.Worksheets.Count)
With ActiveSheet
' Renommer la feuille au mois suivant
.Name = nomNewWS
End With
End Sub
' -------------------------------------------------------------------------------
Public Function VerifFeuille(wsFeuil As String)
Application.ScreenUpdating = False
Dim WS As Integer
VerifFeuille = False
' Boucle sur toutes les feuilles du classeur
For WS = 1 To ThisWorkbook.Worksheets.Count
If Worksheets(WS).Name = wsFeuil Then
VerifFeuille = True
Exit For
End If
Next WS
Application.ScreenUpdating = True
End Function