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
| Private Sub CommandButton1_Click()
Dim DerLigne As Long, j As Long
Dim DerCol As Integer, i As Integer
Dim Flag As Boolean
With Sheets("Calendrier_base")
DerLigne = .Cells(.Rows.Count, "D").End(xlUp).Row
DerCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
.Range(.Cells(2, 3), .Cells(DerLigne, DerCol)).Interior.ColorIndex = xlNone
j = 2
Do
For i = 3 To DerCol
If .Cells(j, i).Value <> "" Then
Debug.Print .Cells(j, i)
Debug.Print Weekday(.Cells(j, i), vbMonday)
If Not Flag Then
Select Case Weekday(.Cells(j, i).Value, vbMonday)
Case 6: .Range(.Cells(j, i), .Cells(j + 1, i)).Interior.ColorIndex = 27
Case 7: .Range(.Cells(j, i), .Cells(j + 1, i)).Interior.ColorIndex = 35
End Select
Set c = .Range("H78:H88").Find(CDate(.Cells(j, i).Value), LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
Set c = Nothing
.Range(.Cells(j, i), .Cells(j + 1, i)).Interior.ColorIndex = 15
End If
Else
Select Case .Cells(j, i)
Case "G": .Range(.Cells(j - 1, i), .Cells(j - 2, i)).Interior.ColorIndex = 45
Case "U": .Range(.Cells(j - 1, i), .Cells(j - 2, i)).Interior.ColorIndex = 45
Case "D": .Range(.Cells(j - 1, i), .Cells(j - 2, i)).Interior.ColorIndex = 42
End Select
End If
End If
Next i
j = j + 2
If Flag Then j = j + 1
Flag = Not Flag
Loop Until j >= DerLigne
Cells(1, 1).Select
End With
End Sub |
Partager