简体   繁体   English

如何根据旁边单元格中的值在excel中为单元格着色?

[英]How can I colour a cell in excel based on the values in the cell next to it?

I've looked in to conditional formatting, but it doesn't manage relative references at all. 我研究了条件格式,但是它根本不管理相对引用。

what I would like to write is something like 我想写的是这样的

 If ( the column number of this cell is more than the value in the first cell of this row) 
   colour it blue
end

It seems something really trivial, but writing something like: 看起来确实很琐碎,但是写的东西却是:

=IF($C$3+4<=COLUMN();COLUMN()-4<=$D$3)

always returns true (I guess ecause it takes COLUMN as a fixed number, say the value it gets the frist time it calls it) and so all cells are blue. 总是返回true(我猜是因为它将COLUMN作为一个固定数字,说它得到它调用的第一时间的值),因此所有单元格都是蓝色的。

that function returns the right value when evaluated inside the function field, but does not work for conditional formatting. 在函数字段中求值时,该函数将返回正确的值,但不适用于条件格式。

What can I do? 我能做什么?

Assuming you want something like this: 假设您想要这样的东西:

SO40679860示例

Select Columns A:H and HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true: : 选择列A:H和HOME>样式-条件格式,新规则..., 使用公式确定要格式化的单元格,在此公式为true的情况下设置值的 格式

=COLUMN()>$A1  

Format... , select choice of formatting, OK , OK . 格式... ,选择格式选择, 确定确定

You can do this with the normal conditional formula itself. 您可以使用常规条件公式本身来执行此操作。 Perform the following steps. 执行以下步骤。

  1. Click on a cell, the first cell that you wanted to color. 单击一个单元格,您要着色的第一个单元格。 Say it is C3 说是C3
  2. Now the default cell becomes your cell C3. 现在,默认单元格成为您的单元格C3。
  3. Click on Conditional formatting options, in that, select "Manage Rules" 点击条件格式设置选项,然后选择“管理规则”
  4. In Conditional formatting rule manage window, click on New Rule button 在条件格式规则管理窗口中,单击“新建规则”按钮
  5. In the new formatting Rule window. 在新的格式规则窗口中。 select Use a formula to determine which cells to format 选择使用公式来确定要格式化的单元格
  6. Enter =(COLUMN(C3) > $A3) in the Format values where this formula is true edit box 在此公式为真的格式值中输入=(COLUMN(C3)> $ A3)编辑框
  7. Select the required color and click ok 选择所需的颜色,然后单击确定
  8. Now copy this cells to all other cells where you want to do the conditional formatting. 现在,将此单元格复制到要进行条件格式化的所有其他单元格。

Here the step 1 and 2 are critical to ensure that it is relative. 在这里,步骤1和2对于确保它是相对的至关重要。

Quite hard to understand what you want without having more informations. 没有更多信息,很难理解您想要什么。 Be that as it may, note that 请注意,

=IF($C$3+4<=COLUMN();COLUMN()-4<=$D$3)

Means 手段

if $C$3+4<=COLUMN() return COLUMN()-4<=$D$3 otherwise return FALSE 如果$C$3+4<=COLUMN()返回COLUMN()-4<=$D$3否则返回FALSE

If it always returns TRUE it is because the tested cells are between the $C$3+4 th and the $D$3+4 th columns AND that $C$3 - $D$3 is a positive number which is sifficiently large for not beeing exceeded by the column number of the cells you test. 如果它总是返回TRUE那是因为测试的单元格在$C$3+4$D$3+4列之间,并且$C$3 - $D$3是一个正数,该数字足够大而不会超出根据您测试的单元格的列号。

暂无
暂无

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

相关问题 如何根据单元格的值更改单元格颜色RGB值? (在Excel中) - How can I make the cell colour RGB value change based on cell's value? (in Excel) 如何根据Excel中的单元格值有条件地设置形状的边框颜色? - How do I conditional format border colour of shape based on cell values in Excel? 根据另一个单元格的单元格颜色更改单元格颜色 excel 2016 - change Cell colour based on cell colour of another cell excel 2016 如何在Excel中创建一个单元格以根据其他单元格的值更改颜色? - How can I make a cell in Excel to change colour according to the value of other cell? 如何比较2个值并在Excel中打印下一个单元格 - How to compare 2 values and print the next cell in Excel Excel:如何根据值更改单元格内容 - Excel: How do I change the Cell Content based on the Values 如何根据同一行中另一个单元格的值更改 Excel (在表格中)中单元格的颜色,并为每个新行重复此操作? - How do I change the colour of a cell in Excel (that's in a Table) based on the value of another cell in the same row and repeat this for each new row? 在Excel中,根据单元格值增加渐变色 - In Excel increment a gradient colour based on cell value 根据 Excel 中的格式更改单元格的颜色 - Change colour of a cell based on it's formatting in Excel 我可以使用nodejs在excel中更改颜色或突出显示单元格吗? - Can I change the colour or highlight cell in excel using nodejs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM