[英]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.