【问题标题】:Highlight cells in a column depending on a letter present in cell range根据单元格范围中存在的字母突出显示列中的单元格
【发布时间】:2015-11-02 12:23:19
【问题描述】:

我有一列指示项目进度(以百分比表示),如果相应行中没有字母 P,则该列应变为红色。使用以下公式会发生非常奇怪的事情:

=ISERROR(FIND("p",$H5:$Y65))

所以我已将P 设置为不是错误,并且不包含P 的单元格应格式化为红色。但是,使用此公式,只有在第一列中有 P 时,即 H 才会格式化。该公式似乎忽略了 H 之后的所有其他列。

有什么建议吗?

【问题讨论】:

    标签: excel excel-formula formula conditional-formatting


    【解决方案1】:

    FIND 没有您所寻求的功能,它在 string 内而不是在 array 内搜索。尝试从相关列中的第 5 行到第 65 行中进行选择,然后在主页 > 样式 - 条件格式、新规则...、使用公式确定要格式化的单元格设置此值的格式公式为真:

    =ISERROR(MATCH("P",$H5:$Y5,0))
    

    Format...,选择红色填充,OK,OK。

    假设P 是整个单元格内容,而不仅仅是一部分。

    【讨论】:

    • 这就像做梦一样!谢谢大家的贡献:)
    【解决方案2】:

    我会重新考虑你的范围,你说相应的行,是 Y65 而不是 Y5 是印刷错误吗?如果您填写当前公式,您将有重叠的单元格,因为下一行将覆盖 H6:Y66,并且将再次检查范围 H6:Y65。

    也就是说,pnuts 是正确的,但是您可以使用用户定义的函数来实现这一点,例如:

    Function BooleanRangeFind(SearchRange As Range, MatchCriteria As String, CaseSensative As Boolean) As Boolean
    Dim Rng As Range
    Dim CurStr As String
    'checks and changes the MatchCriteria to Uppercase, this is
    'the easiest way to ignore case sensativity
    If CaseSensative = False Then MC = UCase(MatchCriteria)
    'iterates through each cell in the range and checks for the MatchCriteria
    'in each cell
    For Each Rng In SearchRange
        'Case Sensativity Check
        If CaseSensative = False Then
            CurStr = UCase(Rng.Value)
        Else
            CurStr = Rng.Value
        End If
        If InStr(1, CurStr, MC) <> 0 Then
        'If the MC is in the Current Range
        'the formula stops looking and returns
        'a true
            BooleanRangeFind = True
            Exit Function
        End If
    Next Rng
    'Default Value is False
    BolleanRangeFind = False
    End Function
    

    你的公式在哪里

    =BooleanRangeFind($H6:$Y65,"p",False)
    

    或者如果我的假设是正确的:

    =BooleanRangeFind($H6:$Y6,"p",False)
    

    【讨论】:

    • 这将允许您检查 P 是否包含在字符串中,如果 P 是整个单元格内容,pnuts 的解决方案要简单得多。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-13
    • 1970-01-01
    • 1970-01-01
    • 2022-01-27
    • 1970-01-01
    相关资源
    最近更新 更多