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
|
Private Sub CommandButton1_Click()
Dim plage As Range
Dim ligne, colonne As Integer
Dim compteur As Integer
Set plage = Range("G26:H45")
compteur = 1
For ligne = 1 To plage.Rows.Count
For colonne = 1 To plage.Columns.Count
If compteur = 1 Then
'Supprime les MFC existantes
plage.Cells(ligne, colonne).FormatCondition.Delete
'Ajoute une première condition
plage.Cells(ligne, colonne).FormatCondition.Add Type:=xlCellExpression, Formula1:="=(" & plage.Cells(ligne + 1, colonne) & ">0)"
'Modifications de la première condition
With plage.Cells(ligne, colonne).FormatConditions(1)
.Interior.ColorIndex = 4
.Font.ColorIndex = 4
End With
'Ajoute une seconde condition
plage.Cells(ligne, colonne).FormatCondition.Add Type:=xlCellExpression, Formula1:="=(" & plage.Cells(ligne, colonne) & ">0)"
'Modifications de la seconde condition
With plage.Cells(ligne, colonne).FormatContidions(2)
.Interior.ColorIndex = 3
.Font.ColorIndex = 3
End With
End If
If compteur = 2 Then
End If
If compteur = 3 Then
End If
If compteur = 4 Then
compteur = 1
End If
compteur = compteur + 1
Next colonne
Next ligne
End Sub |
Partager