[英]Excel VBA Conditional Formatting Remove Formula
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.