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
|
sub macro ()
Dim i As Long
Dim j As Long
Dim maxcol As Long
Dim maxrow As Long
Dim m As Long 'variable qui recupere la valeur de la semaine de la cellule A1
maxrow = currentws.Range("A65536").End(xlUp).Row
maxcol = currentws.Cells(5, currentws.Cells.Columns.Count).End(xlToLeft).Column
'effacement des couleurs
Application.ScreenUpdating = False
Application.EnableEvents = False
For i = 6 To maxrow
For j = 1 To maxcol
currentws.Cells(i, j).Interior.ColorIndex = xlNone
Next j
Next i
Application.EnableEvents = True
'boucle pour les couleurs
For i = 6 To maxrow
m = currentws.Cells(1, 1).Value 'variable de la semaine en cours
currentws.Range(6 & ":" & maxrow).Select
If currentws.Cells(i, 1).Value = "Done" And Mid(currentws.Cells(i, 8), 12) < m Then
currentws.Cells(i, 8).Interior.ColorIndex = xlNone
currentws.Cells(i, 8).Interior.Color = RGB(54, 204, 204) 'bleu
End If
If Mid(currentws.Cells(i, 8), 12) >= 2 * m Then
Debug.Print Mid(currentws.Cells(i, 8), 11)
currentws.Cells(i, 8).Interior.ColorIndex = xlNone
currentws.Cells(i, 8).Interior.Color = RGB(0, 51, 0) 'vert
End If
If Mid(currentws.Cells(i, 8), 12) < 2 * m Then
currentws.Cells(i, 8).Interior.ColorIndex = xlNone
currentws.Cells(i, 8).Interior.Color = RGB(255, 0, 0) 'rouge
End If
Next i
'pour classer les variables suivant les priorités de 1 à n
currentws.Range(6 & ":" & maxrow).Select
Selection.Sort Key1:=Range("A5"), Order1:=xlAscending, Header:=xlGuess,_
ordercustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
dataoption1:=xlSortNormal
Application.ScreenUpdating = True
end sub |
Partager