简体   繁体   English

根据该行中的其他单元格(条件格式)颜色更改 1 个单元格的颜色

[英]Changing the colour of 1 cell based on other cells (conditionally formatted) colour in that row

I am creating a spreadsheet, I have columns in my table that perform validation checks (columns C to Y) from data from other sheets (uses conditional formatting) with the cells turning green if valid and red if invalid.我正在创建一个电子表格,我的表中有列从其他工作表的数据(使用条件格式)中执行验证检查(列 C 到 Y),如果有效,单元格变为绿色,无效时变为红色。

I would like column B to be red if any of cells in the same row but in column C to Y are shaded red.如果在同一行但在 C 到 Y 列中的任何单元格被阴影为红色,我希望 B 列是红色的。

and if they are all green I would like the cell in column B to be green如果它们都是绿色的,我希望 B 列中的单元格是绿色的

is it possible to do this with conditional or will I need to create a macro, if so does anyone have any pointers on how this would be approached?是否可以有条件地做到这一点,或者我是否需要创建一个宏,如果是这样,是否有人对如何解决这个问题有任何指示?

hopefully what I described makes sense, will happily elaborate希望我描述的有道理,会很高兴地详细说明

any help appreciated任何帮助表示赞赏

You can use a function-based CF rule to apply the coloring.您可以使用基于函数的 CF 规则来应用着色。 Eg: this would return True if there are any cells in rng with a red fill as the result of a CF rule (using the DisplayFormat property of each cell)例如:如果rng有任何单元格作为 CF 规则的结果带有红色填充(使用每个单元格的DisplayFormat属性),这将返回 True

Function AnyRed(rng As Range)
    Dim c As Range, rv As Boolean
    For Each c In rng.Cells
        If c.DisplayFormat.Interior.Color = 255 Then
            rv = True
            Exit For
        End If
    Next c
    AnyRed = rv
End Function

In your "master" cell apply a default green fill, then apply a CF rule using the formula and have that apply a red fill when the formula returns True.在您的“主”单元格中应用默认的绿色填充,然后使用公式应用 CF 规则,并在公式返回 True 时应用红色填充。

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

相关问题 基于单元格颜色的vba msgbox单元格 - vba msgbox cells based on cell colour 根据其他 2 种单元格颜色更改单元格颜色 - Change cell colour based on 2 other cell colours 根据细胞的颜色和其他标准对细胞进行计数 - Counting cells based on their colour and other criteria Excel 条件格式 - 基于一行单元格内的值结束单元格颜色 - Excel Conditional Formatting - end cell colour based on value within a row of cells 读取多个单元格的颜色,并根据颜色将颜色返回到另一个单元格 - Read the colour of multiple cells and depending on the colour, return a colour to another cell 如果单元格中的计算值发生变化,则更改单元格颜色 - Changing cell colour if calculated value in the cell changes based VBA 新手,我需要根据单元格的更新更改单元格颜色 - New to VBA, I need to change cell colour based on updates to cells 有没有一种方法可以比较单元格值,然后根据该值对单元格进行着色 - Is there a way to compare cell values and then colour cells based on the value Excel VBA根据单个单元格的范围设置单元格颜色 - Excel VBA Setting Cell Colour based on range of individual cells 根据一组具有不同颜色的单元格更改单元格颜色 - Change a cell colour based on a group of cells with different colours
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM