Sub Test_pmo()
Columns("A:A").Select
Selection.NumberFormat = "General"
'--- Test d'existence de 3 MFC ---
Dim reponse&
Dim A$
Dim FC As FormatCondition
With Selection
If .FormatConditions.Count = 3 Then
For Each FC In .FormatConditions
A$ = A$ & FC.Formula1 & vbCrLf
Next FC
reponse& = MsgBox(prompt:="Il y a déjà 3 mises en forme." & vbCrLf & vbCrLf & _
A$ & vbCrLf & "Voulez-vous les supprimer ?", _
Buttons:=vbOKCancel + vbDefaultButton2, Title:="Excel n'accepte pas plus de 3 MFC")
If reponse& = vbOK Then
On Error Resume Next
.FormatConditions.Delete
Application.Dialogs(xlDialogConditionalFormatting).Show 'Pour visualiser (inutile)
On Error GoTo 0
End If
Exit Sub
End If
End With
'----------------------------------
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=CHERCHE(STXT(SUPPRESPACE(A1);1;1);A1)-1=0"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.FormatConditions(1).Borders(xlTop)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 10498160
.TintAndShade = 0
End With
End Sub