vdh_xavier
XLDnaute Junior
Bonjour à tous,
Je souhaite faire une mise en forme conditionnelle par VBA et j'y parviens en partie, mais lorsque je veux changer le couleur de police, la macro plante.
En fait tout fonctionne, sauf lorsque j'ajoute la partie With .Font.
Merci d'avance pour votre aide.
Voici mon code :
Sub Mises_en_formes_conditionnelles_2()
Dim DLig As Long
With Sheets("Tableau de bord")
ActiveSheet.Unprotect ("xavier")
DLig = .Range("E" & Rows.Count).End(xlUp).Row
With .Range("G5:G" & DLig)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=ET(G5<>"""";G5<AUJOURDHUI())"
With .FormatConditions(.FormatConditions.Count)
.StopIfTrue = False
.SetFirstPriority
With .Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(102, 51, 0)
.TintAndShade = 0
With .Font
.ColorIndex = RGB(255, 255, 255)
End With
End With
End With
End With
End With
End Sub
Je souhaite faire une mise en forme conditionnelle par VBA et j'y parviens en partie, mais lorsque je veux changer le couleur de police, la macro plante.
En fait tout fonctionne, sauf lorsque j'ajoute la partie With .Font.
Merci d'avance pour votre aide.
Voici mon code :
Sub Mises_en_formes_conditionnelles_2()
Dim DLig As Long
With Sheets("Tableau de bord")
ActiveSheet.Unprotect ("xavier")
DLig = .Range("E" & Rows.Count).End(xlUp).Row
With .Range("G5:G" & DLig)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=ET(G5<>"""";G5<AUJOURDHUI())"
With .FormatConditions(.FormatConditions.Count)
.StopIfTrue = False
.SetFirstPriority
With .Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(102, 51, 0)
.TintAndShade = 0
With .Font
.ColorIndex = RGB(255, 255, 255)
End With
End With
End With
End With
End With
End Sub