1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Option Explicit
Sub NouveauMois()
Dim NomFeuille As String
Dim Mois As Byte
Dim An As Integer
Dim Couleur
Couleur = Array(3, 4, 5, 6, 7, 8, 38, 25, 39, 40, 26, 27)
With ActiveSheet
If .Index <> Sheets.Count Then
MsgBox "Seulement La Dernière Feuille"
Exit Sub
End If
An = Val(Split(.Name, " ")(1))
If An = 0 Then
MsgBox "Nom De La Feuille non Conforme"
Exit Sub
End If
Mois = Month("1/" & Split(.Name, " ")(0))
NomFeuille = Application.Proper(Format(DateAdd("m", 1, DateSerial(An, Mois, 1)), "mmmm yyyy"))
.Copy after:=Sheets(Sheets.Count)
.Unprotect
.Shapes("FeuillePlus").Delete
.Protect
End With
With ActiveSheet
Application.EnableEvents = False
.Range("A2") = Application.Proper(MonthName(Month(DateAdd("m", 1, DateSerial(An, Mois, 1)))))
Application.EnableEvents = True
.Name = NomFeuille
.Tab.ColorIndex = Couleur(Mois - 1)
End With
End Sub |
Partager