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 50
|
Sub MiseEnForme()
Dim Cel As Range
Dim MFC As FormatCondition
Dim Formule As String
Dim CouleurTrait As Integer
Dim CouleurFond As Integer
Dim StyleTrait As Integer
Dim EpaisTrait As Integer
CouleurTrait = 5
CouleurFond = 46
StyleTrait = 1
EpaisTrait = 2
Formule = "=$B$2>$A$2"
Set Cel = Range("D2")
Cel.FormatConditions.Delete
Set MFC = Cel.FormatConditions.Add(xlExpression, , Formule)
With MFC.Borders(xlLeft)
.LineStyle = StyleTrait
.Weight = EpaisTrait
.ColorIndex = CouleurTrait
End With
With MFC.Borders(xlRight)
.LineStyle = StyleTrait
.Weight = EpaisTrait
.ColorIndex = CouleurTrait
End With
With MFC.Borders(xlTop)
.LineStyle = StyleTrait
.Weight = EpaisTrait
.ColorIndex = CouleurTrait
End With
With MFC.Borders(xlBottom)
.LineStyle = StyleTrait
.Weight = EpaisTrait
.ColorIndex = CouleurTrait
End With
MFC.Interior.ColorIndex = CouleurFond
End Sub |