dimanche 31 janvier 2010

Colorier les cellules sous conditions [Dans cet exemple : Attribuer une couleur pour chaque jour de la semaine] sous excel

 
Sub ColorJour()

Dim cell As Range
For Each cell In Range("C:C")
  Select Case cell.Value
    Case Is = "Lundi"
    cell.Interior.ColorIndex = 0
    Case Is = "Mardi"
    cell.Interior.ColorIndex = 3
    Case Is = "Mercredi"
    cell.Interior.ColorIndex = 4
    Case Is = "Jeudi"
    cell.Interior.ColorIndex = 5
    Case Is = "Vendredi"
    cell.Interior.ColorIndex = 6
    Case Is = "Samedi"
    cell.Interior.ColorIndex = 7
    Case Is = "Dimanche"
    cell.Interior.ColorIndex = 8
  End Select
Next
End Sub

Aucun commentaire: