繁体   English   中英

基于单元格中IF公式结果的条件格式

[英]Conditional formatting based on the result of IF formula in the cell

有没有一种方法可以根据单元格中存在的IF条件的结果进行条件格式化,无论它返回什么?

就像如果返回true则将其上色为绿色,如果为false则将其上色为红色

该公式在sheet2 =IF(Sheet3!C35="", Sheet3!B35, Sheet3!C35)上看起来像这样,它可以返回B或C列中的任何值,这使我很难使用硬编码有条件地对其进行格式设置值或范围,因为它们的定义不明确

我想通过这样的宏来做

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False

    If Target.Cells.Count = 1 And Target.Cells.HasFormula Then
            'Logic to check the if condition
    End If

Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

您可以将这些条件规则与if语句放在同一单元格中吗?

绿色配方

=Sheet3!C35=""

红色配方

=Sheet3!C35<>""

编辑:添加图片显示格式。

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM