Is there a way to remove conditional formatting on a cell only if it has a certain formula?
Right now I have
Cells(r, 4).Select
With Selection
.FormatConditions.Item(1).Delete
End With
But I only want it to delete the formatting if the formula
="=ISBLANK(A19)=TRUE"
Does anyone know if that is a possibility?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.