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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
Public Sub AjouterSemaines(intSemDeb As Integer, intSemFin As Integer, _
intJDeb As Integer, intJFin As Integer)
Dim color1 As Long
Dim color2 As Long
Dim i As Integer
Dim j As Integer
Dim sh As Worksheet
Dim jTxt(7) As String
Dim txt As String
On Error GoTo lblFin
Application.ScreenUpdating = False
'Semaines
intSemDeb = 1
intSemFin = 52
'Jours
intJDeb = 1
intJFin = 7
'Couleurs
color1 = RGB(255, 0, 0)
color2 = RGB(0, 0, 255)
'Traitement
jTxt(1) = "L"
jTxt(2) = "M"
jTxt(3) = "Me"
jTxt(4) = "J"
jTxt(5) = "V"
jTxt(6) = "S"
jTxt(7) = "D"
For i = intSemDeb To intSemFin
For j = intJDeb To intJFin
txt = jTxt(j) & " S" & Format(i, "00")
For Each sh In ThisWorkbook.Worksheets
If sh.Name = txt Then
Application.DisplayAlerts = False
sh.Delete
Application.DisplayAlerts = True
Exit For
End If
Next sh
Set sh = ThisWorkbook.Worksheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
sh.Name = txt
If i Mod 2 = 0 Then
sh.Tab.Color = color1
Else
sh.Tab.Color = color2
End If
Set sh = Nothing
Next j
Next i
lblFin:
Application.ScreenUpdating = True
End Sub |
Partager