是否有办法在单元格中删除条件格式,只有它具有某个公式?
现在我有
Cells(r, 4).Select
With Selection
.FormatConditions.Item(1).Delete
End With
但我只想删除格式化公式
="=ISBLANK(A19)=TRUE"
有人知道这是否可能?
答案 0 :(得分:0)
Sub Tester()
ClearFormulaCF Range("A1:A5"), "=ISBLANK(A19)=TRUE"
End Sub
'Remove any CF rule from cells in rng where the CF formula
' matches the one provided
Sub ClearFormulaCF(rng As Range, sFormula As String)
Dim rngCF As Range, c As Range, fc As FormatCondition
On Error Resume Next
'any cells with CF?
Set rngCF = rng.SpecialCells(xlCellTypeAllFormatConditions)
On Error GoTo 0
If rngCF Is Nothing Then Exit Sub 'no CF found
For Each c In rngCF.Cells
For Each fc In c.FormatConditions
If fc.Formula1 = sFormula Then
fc.Delete
Exit For
End If
Next fc
Next c
End Sub