Sub Nouvelle_Saison()
     Const VertFoncé As Long = 2386713, VertClair As Long = 13693658, Blanc As Long = 16777215
     Dim lbl As String, Action As String
     Dim TS, Année As Integer, Nbl As Long, Entête As String, LgnDéb As Long
     
     On Error Resume Next
          lbl = Application.Caller
     On Error GoTo 0
     If lbl <> "Btn_Nouvelle_Saison" Then Exit Sub
     Action = Sh_Décompte.Shapes(lbl).DrawingObject.Caption
     If Not Action Like "Commencer la saison ####" Then Exit Sub
     
     
     TS = Sh_Décompte.[TS_Décompte]
     Synthèse = Sh_Décompte.[Synthèse].Value
     Nbl = UBound(TS, 1)
     Année = Year(CDate(TS(1, 1)))
     Entête = "Saison " & Année & Chr(10) & "du " & Format(DateSerial(Année, 1, 1), "dd/mm/yyyy") & " au " & Format(DateSerial(Année, 12, 31), "dd/mm/yyyy")
     With Sh_Archives
          LgnDéb = .Cells(.Rows.Count, 10).End(xlUp).Row + 1
          LgnDéb = LgnDéb + Abs(LgnDéb <> 2)
          'Titre
          With .Cells(LgnDéb, 2).Resize(1, 9)
               .Merge
               .Borders.LineStyle = xlContinuous
               .Borders.Color = VertFoncé
               .Value = "Saison " & Année
               .HorizontalAlignment = xlLeft
               .InsertIndent 1
               .VerticalAlignment = xlCenter
               .Font.Size = 18
               .Font.Bold = True
               .Font.Color = VertFoncé
               .Interior.Color = VertClair
          End With
          
          'Entêtes colonnes
          With .Cells(LgnDéb + 1, 2).Resize(1, 9)
               .WrapText = True
               .Borders(xlInsideVertical).LineStyle = xlContinuous
               .Borders(xlInsideVertical).Color = Blanc
               .Borders(xlEdgeLeft).LineStyle = xlContinuous
               .Borders(xlEdgeLeft).Color = VertFoncé
               .Borders(xlEdgeRight).LineStyle = xlContinuous
               .Borders(xlEdgeRight).Color = VertFoncé
               .HorizontalAlignment = xlCenter
               .VerticalAlignment = xlCenter
               .Font.Size = 11
               .Font.Bold = True
               .Font.Color = Blanc
               .Interior.Color = VertFoncé
               .Cells(1).Value = "Date"
               .Cells(2).Value = "Compteur"
               .Cells(3).Value = "Libellé"
               .Cells(4).Value = "Complément de libellé"
               .Cells(5).Value = "Acheté"
               .Cells(6).Value = "Prix au 100 l"
               .Cells(7).Value = "Montant payé"
               .Cells(8).Value = "Quantité utilisée"
               .Cells(9).Value = "Solde (litres)"
          End With
          
          'Relevés
          With .Cells(LgnDéb + 2, 2).Resize(Nbl, 9)
               .Value = TS
               .Borders.LineStyle = xlContinuous
               .Borders.Color = VertFoncé
               .Columns(1).NumberFormat = "dd/mm/yyyy"
               Union(.Columns(2), .Columns(5), .Columns(8), .Columns(9)).NumberFormat = "# ##0"
               .Columns(6).Resize(, 2).NumberFormat = "# ##0.00"
          End With
          
          'Entêtes Synthèse
          With .Cells(LgnDéb + Nbl + 2, 2).Resize(Nbl, 9)
               With .Resize(2, 3)
                    .Merge
                    .Borders.LineStyle = xlContinuous
                    .Borders.Color = VertFoncé
                    .Value = "Synthèse " & Entête
                    .HorizontalAlignment = xlLeft
                    .InsertIndent 3
                    .WrapText = True
                    .VerticalAlignment = xlCenter
                    .Font.Size = 12
                    .Font.Bold = True
                    .Font.Color = VertFoncé
                    .Interior.Color = VertClair
               End With
               With .Offset(0, 3).Resize(1, 6)
                    .Borders(xlInsideVertical).LineStyle = xlContinuous
                    .Borders(xlInsideVertical).Color = Blanc
                    .Borders(xlEdgeLeft).LineStyle = xlContinuous
                    .Borders(xlEdgeLeft).Color = VertFoncé
                    .Borders(xlEdgeRight).LineStyle = xlContinuous
                    .Borders(xlEdgeRight).Color = VertFoncé
                    .WrapText = True
                    .Interior.Color = VertFoncé
                    .Font.Color = 16777215
                    .Font.Bold = True
                    .HorizontalAlignment = xlCenter
                    .VerticalAlignment = xlCenter
                    .Cells(1).Value = "Compteur"
                    .Cells(2).Value = "Quantité utilisée"
                    .Cells(3).Value = "Prix moyen au 100 l"
                    .Cells(4).Value = "Montant payé"
                    .Cells(5).Value = "Quantité achetée"
                    .Cells(6).Value = "Solde (litres)"
               End With
               
               'Valeurs Synthèse
               With .Offset(1, 3).Resize(1, 6)
                    .Borders.LineStyle = xlContinuous
                    .Borders.Color = VertFoncé
                    .WrapText = True
                    .HorizontalAlignment = xlRight
                    .VerticalAlignment = xlCenter
                    Union(.Cells(1), .Cells(2), .Cells(5), .Cells(6)).NumberFormat = "# ##0"
                    Union(.Cells(3), .Cells(4)).NumberFormat = "# ##0.00"
                    .Cells(1).Value = Synthèse(1, 2)
                    .Cells(2).Value = Synthèse(1, 5)
                    .Cells(3).Value = Synthèse(1, 6)
                    .Cells(4).Value = Synthèse(1, 7)
                    .Cells(5).Value = Synthèse(1, 8)
                    .Cells(6).Value = Synthèse(1, 9)
               End With
          End With
     End With
     With Sh_Décompte.[TS_Décompte]
          .ClearContents
          .ListObject.Resize .Offset(-1, 0).Resize(2)
          .Cells(1, 7).FormulaLocal = "=SI(ET([@Acheté]<>"""";[@[Prix au 100 l]]<>"""");ARRONDI(([@Acheté]*[@[Prix au 100 l]])/100;2);"""")"
          .Cells(1, 8).FormulaLocal = "=SI(ESTFORMULE([@[Solde (litres)]]);SI(OU(Lgn=1;[@Compteur]="""");"""";LET(Préc;DECALER([@Compteur];-1;0);SI(Préc>[@Compteur];"""";[@Compteur]-Préc)));DECALER([@[Solde (litres)]];-1;0)-[@[Solde (litres)]])"
          .Cells(1, 9).FormulaLocal = "=SI((Lgn=1)+([@Libellé]=""SOLDE"");SI([@Acheté]="""";"""";[@Acheté]);DECALER([@[Solde (litres)]];-1;0)-CNUM(0&[@[Quantité utilisée]])+[@Acheté])"
          .Cells(1, 1).Value = DateSerial(Année + 1, 1, 1)
          .Cells(1, 2).Value = Synthèse(1, 2)
          .Cells(1, 3).Value = "Solde"
          .Cells(1, 4).Value = "Saison " & Année + 1
          .Cells(1, 5).Value = Synthèse(1, 9)
          .Cells(1, 6).Value = Synthèse(1, 6)
     End With
     MsgBox Title:="Nouvelle saison année " & Année + 1, Prompt:="La saison " & Année & " a été archivée" & Chr(10) & "(voir la feuille ""Archives Décompte"")"
     
End Sub