Function RetourPrévu(D)
RetourPrévu = ""
DerCol = Cells(2, Cells.Columns.Count).End(xlToLeft).Column
Ligne = D.Row
ColToDay = 0
For C = 7 To DerCol
If Cells(2, C) = Date Then ColToDay = C
Next C
If ColToDay = 0 Then Exit Function
If Cells(Ligne, ColToDay).Interior.Color <> RGB(255, 255, 255) Then
' Cas où la cellule d'aujourd'hui est en couleur, on cherche la prochaine transition
For C = ColToDay To DerCol
If Cells(Ligne, C).Interior.Color <> RGB(255, 255, 255) And _
Cells(Ligne, C + 1).Interior.Color = RGB(255, 255, 255) Then
RetourPrévu = CDate(Format(Cells(2, C), "[$-40C]dd-mmm;@"))
Exit Function
End If
Next C
Else
' Cas où la cellule d'aujourd'hui est blanche, on cherche la dernière transition
For C = ColToDay To 7 Step -1
If Cells(Ligne, C).Interior.Color <> RGB(255, 255, 255) And _
Cells(Ligne, C + 1).Interior.Color = RGB(255, 255, 255) Then
RetourPrévu = CDate(Format(Cells(2, C), "[$-40C]dd-mmm;@"))
Exit Function
End If
Next C
End If
End Function