Option Explicit
Dim F As Worksheet, Cell As Range, lg&, i&
Sub Config()
    Sheets("Données").Select
End Sub
Sub bilan()
    Sheets("Bilan").Select
End Sub
Sub Accueil()
    Sheets("Accueil").Select
End Sub
Sub Clear()
Application.ScreenUpdating = False
Dim debut!, temps!, WS As Worksheet, wss As Worksheet
Application.Calculation = xlCalculationManual
debut = Timer
 
For Each WS In Sheets(Array("HJanvier", "HFevrier", "HMars", "HAvril", "HMai", "HJuin", _
                           "HJuillet", "HAout", "HSeptembre", "HOctobre", "HNovembre", _
                           "HDecembre", "Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", _
                           "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"))
      Forme WS
      couleurhaute WS
      Feriee WS
      couleurseparateur WS
      clearcol WS
      border WS
      borderinfo WS
      newsy

Next
temps = CInt(Timer - debut)
Application.Calculation = xlCalculationAutomatic
MsgBox ("C'est fini !" & Chr(10) & "temps de traitement :" & Chr(13) & temps & " secondes")
End Sub
Sub newsy()
Application.ScreenUpdating = False
Dim WS As Worksheet
Dim debut!, temps!
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
debut = Timer
For Each WS In Sheets(Array("Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", _
                           "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"))
                        
  WS.Unprotect ("azerty")
  WS.Range("B66:AG66").ClearFormats
  WS.Range("B5:AG5").ClearFormats
  WS.Range("B5:AG5").ClearContents
  WS.Range("B67:AJ9").ClearContents
  WS.Range("B9:AJ66").ClearContents
  WS.Range("AS9:AS66").ClearContents
  WS.Protect ("azerty"), DrawingObjects:=True, Contents:=True, Scenarios:=True _
                       , AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowFiltering:=True
Next
temps = CInt(Timer - debut)
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
MsgBox ("C'est fini !" & Chr(10) & "temps de traitement :" & Chr(13) & temps & " secondes")
End Sub
Sub Miseenforme()
Dim WS As Worksheet
Dim debut!, temps!
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
debut = Timer

For Each WS In Sheets(Array("Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", _
                           "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre", _
                           "HJanvier", "HFevrier", "HMars", "HAvril", "HMai", "HJuin", _
                           "HJuillet", "HAout", "HSeptembre", "HOctobre", "HNovembre", _
                           "HDecembre"))
          unlockedall
          clearcol WS
          Forme WS
          couleurhaute WS
          Feriee WS
          couleurseparateur WS
          couleurtitre WS
          border WS
          borderinfo WS
          Filtre WS
          lockedall
          Sheets("Accueil").Select
        Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
MsgBox ("C'est fini !" & Chr(10) & "temps de traitement :" & Chr(13) & temps & " secondes")
End Sub
Sub Forme(WS As Worksheet)
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim Col%
   With WS
For Col = 2 To 33
   If Left(WS.Name, 1) = "H" Then
        .Columns(Col).ColumnWidth = 8
   Else
   .Columns(Col).ColumnWidth = 4
   .Columns(1).ColumnWidth = 20
   .Columns(34).ColumnWidth = 8
   .Columns(35).ColumnWidth = 8
   .Columns(36).ColumnWidth = 8
   .Columns(38).ColumnWidth = 8
   .Columns(39).ColumnWidth = 8
   .Columns(40).ColumnWidth = 8
   .Columns(42).ColumnWidth = 8
   .Columns(43).ColumnWidth = 8
   .Columns(45).ColumnWidth = 8
   .Columns(46).ColumnWidth = 8
   .Columns(47).ColumnWidth = 8
   .Columns(48).ColumnWidth = 8
   .Columns(49).ColumnWidth = 8
   .Columns(50).ColumnWidth = 8
   .Columns(52).ColumnWidth = 8
   .Columns(53).ColumnWidth = 8
   .Columns(54).ColumnWidth = 8
   .Columns(55).ColumnWidth = 8
   .Columns(56).ColumnWidth = 8
   .Columns(57).ColumnWidth = 8
   .Columns(58).ColumnWidth = 8
      End If
      Next Col
End With
End Sub
Sub couleurtitre(WS As Worksheet)
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim i%, wss As Worksheet
Set wss = ThisWorkbook.Worksheets("Données")
With WS
     For i = 1 To 1
             wss.Range("X17").Copy: .Range(.Cells(6, i), .Cells(6, i)).PasteSpecial xlPasteFormats
             wss.Range("Y17").Copy: .Range(.Cells(7, i), .Cells(7, i)).PasteSpecial xlPasteFormats
      Next
End With
End Sub
Sub couleurhaute(WS As Worksheet)
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim i%, wss As Worksheet
Set wss = ThisWorkbook.Worksheets("Données")
With WS
   If Left(WS.Name, 1) = "H" Then
      For i = 2 To 33
         If .Cells(6, i) = "Samedi" Or .Cells(6, i) = "Dimanche" Then
            wss.Range("Z17").Copy: .Range(.Cells(6, i), .Cells(7, i)).PasteSpecial xlPasteFormats
            wss.Range("Z20").Copy: .Range(.Cells(9, i), .Cells(65, i)).PasteSpecial xlPasteFormats
         ElseIf Cells(6, i) <> " " Then
            wss.Range("Y17").Copy: .Range(.Cells(6, i), .Cells(7, i)).PasteSpecial xlPasteFormats
            wss.Range("Y20").Copy: .Range(.Cells(9, i), .Cells(65, i)).PasteSpecial xlPasteFormats
         End If
      Next
   Else
      For i = 2 To 33
         If .Cells(6, i) = "S" Or .Cells(6, i) = "D" Then
                wss.Range("Z17").Copy: .Range(.Cells(6, i), .Cells(7, i)).PasteSpecial xlPasteFormats
            wss.Range("Z20").Copy: .Range(.Cells(9, i), .Cells(65, i)).PasteSpecial xlPasteFormats
         ElseIf Cells(6, i) <> " " Then
            wss.Range("Y17").Copy: .Range(.Cells(6, i), .Cells(7, i)).PasteSpecial xlPasteFormats
            wss.Range("Y20").Copy: .Range(.Cells(9, i), .Cells(65, i)).PasteSpecial xlPasteFormats
         End If
      Next
   End If
End With
End Sub
Sub couleurseparateur(WS As Worksheet)
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim i%, wss As Worksheet
Set wss = ThisWorkbook.Worksheets("Données")
With WS
.Range(.Cells(9, "AG"), .Cells(9, "BF")).Copy: .Range(.Cells(10, "AG"), .Cells(65, "BF")).PasteSpecial xlPasteFormats
wss.Range("X21").Copy: .Range(.Cells(9, "A"), .Cells(65, "A")).PasteSpecial xlPasteFormats
      For i = 8 To 65
         If .Cells(i, "A") = wss.Range("x26") And wss.Range("x26") <> "" Or _
            .Cells(i, "A") = wss.Range("x27") And wss.Range("x27") <> "" Or _
            .Cells(i, "A") = wss.Range("x28") And wss.Range("x28") <> "" Or _
            .Cells(i, "A") = wss.Range("x29") And wss.Range("x29") <> "" Or _
            .Cells(i, "A") = wss.Range("x30") And wss.Range("x30") <> "" Or _
            .Cells(i, "A") = wss.Range("x31") And wss.Range("x31") <> "" Or _
            .Cells(i, "A") = wss.Range("x32") And wss.Range("x32") <> "" Or _
            .Cells(i, "A") = wss.Range("x33") And wss.Range("x33") <> "" Or _
            .Cells(i, "A") = wss.Range("x34") And wss.Range("x34") <> "" Then
            wss.Range("X19").Copy: .Cells(i, "A").PasteSpecial xlPasteFormats
            wss.Range("Y19").Copy: .Range(.Cells(i, "B"), .Cells(i, "BF")).PasteSpecial xlPasteFormats
            
      
   End If
   Next
    For i = 8 To 65
         If .Cells(i, "A") = wss.Range("x26") And wss.Range("x26") = "" Or _
            .Cells(i, "A") = wss.Range("x27") And wss.Range("x27") = "" Or _
            .Cells(i, "A") = wss.Range("x28") And wss.Range("x28") = "" Or _
            .Cells(i, "A") = wss.Range("x29") And wss.Range("x29") = "" Or _
            .Cells(i, "A") = wss.Range("x30") And wss.Range("x30") = "" Or _
            .Cells(i, "A") = wss.Range("x31") And wss.Range("x31") = "" Or _
            .Cells(i, "A") = wss.Range("x32") And wss.Range("x32") = "" Or _
            .Cells(i, "A") = wss.Range("x33") And wss.Range("x33") = "" Or _
            .Cells(i, "A") = wss.Range("x34") And wss.Range("x34") = "" Then
            wss.Range("X21").Copy: .Cells(i, "A").PasteSpecial xlPasteFormats
      
   End If
   Next
End With
End Sub
Sub Feriee(WS As Worksheet)
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim i%, wss As Worksheet
Set wss = ThisWorkbook.Worksheets("Données")
With WS
      For i = 2 To 33
         If .Cells(2, i) = wss.Range("AI20") Or _
            .Cells(2, i) = wss.Range("AI21") Or _
            .Cells(2, i) = wss.Range("AI22") Or _
            .Cells(2, i) = wss.Range("AI23") Or _
            .Cells(2, i) = wss.Range("AI24") Or _
            .Cells(2, i) = wss.Range("AI25") Or _
            .Cells(2, i) = wss.Range("AI26") Or _
            .Cells(2, i) = wss.Range("AI27") Or _
            .Cells(2, i) = wss.Range("AI28") Or _
            .Cells(2, i) = wss.Range("AI29") Or _
            .Cells(2, i) = wss.Range("AI30") Or _
            .Cells(2, i) = wss.Range("AI31") Or _
            .Cells(2, i) = wss.Range("AI32") Then
            wss.Range("Z17").Copy: .Range(.Cells(6, i), .Cells(7, i)).PasteSpecial xlPasteFormats
            wss.Range("Z20").Copy: .Range(.Cells(9, i), .Cells(65, i)).PasteSpecial xlPasteFormats
      
   End If
   Next
End With
End Sub
Sub clearcol(WS As Worksheet)
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
With WS
   For i = 29 To 75
      If .Cells(7, i) = "" Then .Range(.Cells(5, i), .Cells(67, i)).Clear
      If .Cells(7, i) = "" Then .Range(.Cells(5, i), .Cells(67, i)).ClearFormats
      Next
End With
End Sub
Sub border(WS As Worksheet)
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
    With WS
            If WS.Name = "Fevrier" Or WS.Name = "HFevrier" Then
            .Range(.Cells(6, "B"), .Cells(65, "AD")).Borders(xlEdgeBottom).Weight = xlMedium
            .Range(.Cells(6, "B"), .Cells(65, "AD")).Borders(xlEdgeRight).Weight = xlMedium
    
            ElseIf WS.Name = "Avril" Or _
            WS.Name = "HAvril" Or _
            WS.Name = "Juin" Or _
            WS.Name = "HJuin" Or _
            WS.Name = "Septembre" Or _
            WS.Name = "HSeptembre" Or _
            WS.Name = "Novembre" Or _
            WS.Name = "HNovembre" Then
            .Range(.Cells(6, "B"), .Cells(65, "AE")).Borders(xlEdgeBottom).Weight = xlMedium
            .Range(.Cells(6, "B"), .Cells(65, "AE")).Borders(xlEdgeRight).Weight = xlMedium
            
            ElseIf WS.Name = "Janvier" Or _
            WS.Name = "HJanvier" Or _
            WS.Name = "Mars" Or _
            WS.Name = "HMars" Or _
            WS.Name = "Mai" Or _
            WS.Name = "HMai" Or _
            WS.Name = "Juillet" Or _
            WS.Name = "HJuillet" Or _
            WS.Name = "Aout" Or _
            WS.Name = "HAout" Or _
            WS.Name = "Octobre" Or _
            WS.Name = "HOctobre" Or _
            WS.Name = "Decembre" Or _
            WS.Name = "HDecembre" Then
             .Range(.Cells(6, "B"), .Cells(65, "AF")).Borders(xlEdgeBottom).Weight = xlMedium
             .Range(.Cells(6, "B"), .Cells(65, "AF")).Borders(xlEdgeRight).Weight = xlMedium
         End If
    End With
    End Sub
Sub borderinfo(WS As Worksheet)
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
With WS
        If WS.Name = "Janvier" Then
             .Range(.Cells(6, "AI"), .Cells(65, "AR")).Borders(xlInsideVertical).Weight = xlMedium
             .Range(.Cells(6, "AI"), .Cells(65, "AI")).Borders(xlEdgeLeft).Weight = xlMedium
             .Range(.Cells(6, "AR"), .Cells(65, "AR")).Borders(xlRight).Weight = xlMedium
             .Range(.Cells(6, "AT"), .Cells(65, "AT")).Borders(xlEdgeLeft).Weight = xlMedium
             .Range(.Cells(6, "AH"), .Cells(65, "AH")).Borders(xlEdgeLeft).Weight = xlMedium
             .Range(.Cells(6, "AV"), .Cells(65, "AV")).Borders(xlEdgeLeft).Weight = xlMedium
             .Range(.Cells(6, "AV"), .Cells(65, "AV")).Borders(xlEdgeRight).Weight = xlMedium
             .Range(.Cells(6, "AZ"), .Cells(65, "AZ")).Borders(xlEdgeLeft).Weight = xlMedium
             .Range(.Cells(6, "BE"), .Cells(65, "BE")).Borders(xlEdgeRight).Weight = xlMedium
        
          ElseIf WS.Name = "Fevrier" Or _
                        WS.Name = "Mars" Or _
                        WS.Name = "Avril" Or _
                        WS.Name = "Mai" Or _
                        WS.Name = "Juin" Or _
                        WS.Name = "Juillet" Or _
                        WS.Name = "Aout" Or _
                        WS.Name = "Septembre" Or _
                        WS.Name = "Octobre" Or _
                        WS.Name = "Novembre" Or _
                        WS.Name = "Decembre" Then
                         .Range(.Cells(6, "AI"), .Cells(65, "AR")).Borders(xlInsideVertical).Weight = xlMedium
                         .Range(.Cells(6, "AI"), .Cells(65, "AI")).Borders(xlEdgeLeft).Weight = xlMedium
                         .Range(.Cells(6, "AH"), .Cells(65, "AH")).Borders(xlEdgeLeft).Weight = xlMedium
                         .Range(.Cells(6, "AV"), .Cells(65, "aV")).Borders(xlEdgeLeft).Weight = xlMedium
                         .Range(.Cells(6, "AV"), .Cells(65, "AV")).Borders(xlEdgeRight).Weight = xlMedium
                         .Range(.Cells(6, "AZ"), .Cells(65, "AZ")).Borders(xlEdgeLeft).Weight = xlMedium
                         .Range(.Cells(6, "B"), .Cells(65, "BE")).Borders(xlEdgeRight).Weight = xlMedium
End If
End With
End Sub
Sub Filtre(WS As Worksheet)
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
 With WS
     For i = 7 To 67
     WS.Unprotect ("azerty")
             .Range(.Cells(i, "A"), .Cells(i, "A")).AutoFilter Field:=1, Criteria1:="<>", Visibledropdown:=False
      Next
End With
End Sub
Sub unlockedall()
Dim WS As Worksheet
    Application.ScreenUpdating = False
        For Each WS In Sheets(Array("Janvier", "Fevrier", "Mars", "Avril", _
                                   "Mai", "Juin", "Juillet", "Aout", "Septembre", _
                                   "Octobre", "Novembre", "Decembre", _
                                   "HJanvier", "HFevrier", "HMars", "HAvril", _
                                   "HMai", "HJuin", "HJuillet", "HAout", "HSeptembre", _
                                   "HOctobre", "HNovembre", "HDecembre", _
                                   "BJanvier", "BFevrier", "BMars", "BAvril", _
                                   "BMai", "BJuin", "BJuillet", "BAout", "BSeptembre", _
                                   "BOctobre", "BNovembre", "BDecembre"))
                                   
                      WS.Unprotect ("azerty")
                      Next
    Application.ScreenUpdating = True
End Sub
Sub lockedall()
Dim WS As Worksheet
    Application.ScreenUpdating = False
        For Each WS In Sheets(Array("Janvier", "Fevrier", "Mars", "Avril", _
                                   "Mai", "Juin", "Juillet", "Aout", "Septembre", _
                                   "Octobre", "Novembre", "Decembre", _
                                   "HJanvier", "HFevrier", "HMars", "HAvril", _
                                   "HMai", "HJuin", "HJuillet", "HAout", "HSeptembre", _
                                   "HOctobre", "HNovembre", "HDecembre", _
                                   "BJanvier", "BFevrier", "BMars", "BAvril", _
                                   "BMai", "BJuin", "BJuillet", "BAout", "BSeptembre", _
                                   "BOctobre", "BNovembre", "BDecembre"))
                                   
                       WS.Protect ("azerty"), DrawingObjects:=True, Contents:=True, Scenarios:=True _
               , AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowFiltering:=True
                      Next
    Application.ScreenUpdating = True
End Sub


