基于另一个工作表和单元格中的值格式化单元格颜色 [英] Format cell color based on value in another sheet and cell

查看:81
本文介绍了基于另一个工作表和单元格中的值格式化单元格颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张两张工作簿。我想根据表2第二列中的值格式化表格1的第一列中的单元格背景颜色。



例如,如果的sheet2,第6列,第2列是说4,那么我想要的表格1,第4列第1列的背景颜色为绿色。如果第2列第2列中的任何值都不参考表1中的特定行,我想将其设置为无颜色。在表2的第二列中没有禁止多次出现相同的值。如果可以告诉我如何清除第2页中指向表1中的一行的最后一个值,那么可以告诉我如何取消设置颜色。 >

我相信,对于Excel向导,这可能是微不足道的,但我很少有机会使用excel,当然没有时间成为一个黑带。任何人都可以提供建议,指针或快速公式来做到这一点吗?如果这需要一些复杂的VB代码来实现,那不值得。



谢谢!

解决方案

这是我在Excel 2003中使用条件格式化的方式。



要将条件格式应用于 Sheet1 使用 Sheet2 中的值,您需要将值镜像到 Sheet1 。 / p>

在Sheet 1中创建Sheet2的列B的镜像




  1. 转到 Sheet1

  2. 右键单击列A的标题并选择插入插入新列。

  3. 在A1中输入以下公式:



    = IF(ISBLANK(Sheet2!B1),,Sheet2!B1 )


  4. 右键单击 A1 并选择$ code>复制。

  5. 将公式粘贴到列 A 中,右键单击其标题并选择粘贴

Sheet1 ,列 A 现在应该完全反映 Sheet2 ,列 B



(注意:如果您不喜欢列 A ,它也可以在列 Z 或其他任何地方。)



应用条件格式化




  1. 保持在 Sheet1

  2. B 通过左键单击其标题。
  3. 选择菜单项格式>条件格式。

  4. 条件1 更改为 / code>并输入以下公式:



    = MATCH(B1,$ A:$ A,0)


  5. 点击格式... 按钮,然后选择一个绿色背景。 >


您现在应该看到绿色背景应用于 Sheet1中的匹配单元格



隐藏镜像列




  1. 保持页1

  2. 右键单击列 A 上的标题,然后选择

这应该会自动更新 Sheet1 每当 Sheet2 中的任何内容发生变化。


I have a workbook with two sheets. I would like to format the cell background color in the first column of sheet 1 based on the values in the second column of sheet 2.

For example, if the value of of sheet2, row 6, column 2 is say, 4, then I would like the background color of sheet 1, row 4, column 1 to be green. If none of the values in sheet 2, column 2 reference a particlar row in sheet 1, I'd like to leave it set to no color. There's no prohibition against the same value appearing multiple times in the second column of sheet 2. Bonus kudos if you can tell me how to unset the color if the last value in sheet 2 pointing to a row in sheet 1 is removed.

I'm sure that for the Excel wizards out there this could be trivial, but I rarely have occasion to use excel and certainly don't have time to become a black belt in it. Can anyone offer me advice, pointers, or a quick formula to do this? If this is going to take some complex VB code to implement, it isn't worth it.

Thank you!

解决方案

Here's how I did it in Excel 2003 using conditional formatting.

To apply conditional formatting to Sheet1 using values from Sheet2, you need to mirror the values into Sheet1.

Creating a mirror of Sheet2, column B in Sheet 1

  1. Go to Sheet1.
  2. Insert a new column by right-clicking column A's header and selecting "Insert".
  3. Enter the following formula into A1:

    =IF(ISBLANK(Sheet2!B1),"",Sheet2!B1)

  4. Copy A1 by right-clicking it and selecting "Copy".
  5. Paste the formula into column A by right-clicking its header and selecting "Paste".

Sheet1, column A should now exactly mirror the values in Sheet2, column B.

(Note: if you don't like it in column A, it works just as well to have it in column Z or anywhere else.)

Applying the conditional formatting

  1. Stay on Sheet1.
  2. Select column B by left-clicking its header.
  3. Select the menu item Format > Conditional Formatting...
  4. Change Condition 1 to "Formula is" and enter this formula:

    =MATCH(B1,$A:$A,0)

  5. Click the Format... button and select a green background.

You should now see the green background applied to the matching cells in Sheet1.

Hiding the mirror column

  1. Stay on Sheet1.
  2. Right-click the header on column A and select "Hide".

This should automatically update Sheet1 whenever anything in Sheet2 is changed.

这篇关于基于另一个工作表和单元格中的值格式化单元格颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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