(Excel)基于相邻单元格值的条件格式 [英] (Excel) Conditional Formatting based on Adjacent Cell Value

查看:411
本文介绍了(Excel)基于相邻单元格值的条件格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图基于相邻单元格的值在Excel中对一系列单元格应用条件格式,以实现如下所示:

I'm trying to apply conditional formatting in Excel on a range of cells, based on the adjacent cell's value, to achieve something like this:

目标是突出显示B列中的值(实际支出)红色,如果该值大于C列中的相邻值(预期支出)。我关注了许多教程,这些教程通过选择 Conditional Formatting> New Rules>使用公式确定要格式化的单元格,然后应用规则= $ B4> $ C4来应用条件格式。如果实际单元格大于预期单元格,则将其格式设置为红色。这对于一个单元格效果很好,但是当我尝试将其应用于一系列单元格时效果不是很好。我已经使用了格式绘制器,还编辑了要应用于一系列单元格(即$ B $ 2:$ B $ 5)的规则,如下所示,但它仅基于初始公式设置格式(如果B4大于C4),所有内容均会变成红色。

The goal is to highlight values in Column B (Actual Expense) red if the value is greater than it's adjacent value in column C (Expected Expense). I've followed a number of tutorials that said to apply conditional formatting by selecting Conditional Formatting>New Rules>Use a Formula to Determine Which Cells to Format then applying a rule =$B4>$C4 which would format the 'Actual' cell red if it were greater than the 'Expected' cell. This works great for one cell, but not so well when I attempt to apply this to a range of cells. I've used the format painter as well as editing the rule to be applied over a range of cells (i.e. $B$2:$B$5) as shown below but it only bases the formatting on the initial formula (if B4 is greater than C4) and everything undesirably turns red.

I宁愿不为每一行制定单独的规则。有没有一种方法可以将其合并为一条规则?

I'd rather not make individual rules for every row. Is there a way to consolidate this into one rule?

推荐答案

您需要在行号之前取出$符号。公式...。并且公式中使用的行号应与数据的第一行相对应,因此,如果将其应用于(应用于)范围$ B $ 2:$ B $ 5必须是此公式

You need to take out the $ signs before the row numbers in the formula....and the row number used in the formula should correspond to the first row of data, so if you are applying this to the ("applies to") range $B$2:$B$5 it must be this formula

= $ B2> $ C2

通过使用相对版本而不是绝对版本的Excel(隐式)调整范围内每一行的公式,就好像您要向下复制公式

by using that "relative" version rather than your "absolute" one Excel (implicitly) adjusts the formula for each row in the range, as if you were copying the formula down

这篇关于(Excel)基于相邻单元格值的条件格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆