Sub Colorize()
Dim Lastcell As Variant
Dim Columncolor As Variant
Dim NbCol As Integer
Dim NbLig As Integer
Dim colonnesgauche As Integer
Dim Nbcolleft As Integer
Dim Nbcolright As Integer
Dim CurrentDate As Date
Dim CurrentMonth As Variant
Dim Months(11) As Integer
Dim I As Long
Dim J As Long
Dim Testcolumn As Integer
Dim formula As String
Dim proratecolumn As Integer
Dim totalfcstqty As Variant
Dim colonnesdroite As Integer
Dim Debutdroite As Integer
Dim findroite As Integer
Dim Year As Integer
NbLig = ActiveSheet.UsedRange.Rows.Count
NbCol = ActiveSheet.UsedRange.Columns.Count
'Gestion du remplissage des mois de forecast
Nbcolleft = 22
Nbcolright = 33
Testcolumn = 20
CurrentDate = Range("J1").Value
CurrentMonth = Month(CurrentDate)
'init tableau des mois
'I = 0
'While I < 12
' Months(I) = Nbcolleft + I
' I = I + 1
'Wend
Months(0) = 31
Months(1) = 32
Months(2) = 33
Months(3) = 22
Months(4) = 23
Months(5) = 24
Months(6) = 25
Months(7) = 26
Months(8) = 27
Months(9) = 28
Months(10) = 29
Months(11) = 30
For I = 3 To NbLig
For J = Nbcolleft To Nbcolright
If Cells(I, Testcolumn).Value = "Sales" Then
Cells(I, J).Interior.Color = RGB(102, 255, 255)
ElseIf Cells(I, Testcolumn).Value = "Estimate" Then
If J < Months(CurrentMonth - 1) Then
Cells(I, J).Interior.Color = RGB(102, 255, 255)
Else: Cells(I, J).Interior.Color = RGB(247, 150, 70)
End If
ElseIf Cells(I, Testcolumn).Value = "Forecast" Then
Cells(I, J).Interior.Color = RGB(247, 150, 70)
End If
Next J
Next I
'Mise en forme des colonnes de gauche
colonnesgauche = 4
Year = 21
For I = 4 To NbLig
For J = 1 To colonnesgauche
Cells(I, J).Select
Selection.Interior.Color = RGB(255, 204, 153)
Selection.HorizontalAlignment = xlCenter
Next J
Next I
Endsub