简体   繁体   中英

Is it Possible to Color a Column/Row of Cells based on another Column/Row of Cells?

There are two columns; the first contains four colored cells, while the second contains numbers. Is there any way to color the second column so that it matches the colors of the first column in the same order.

Eg. A1=Green, A2=Red, A3=Grey, A4=Black (COLORED). B1=4, B2=3, B3=2, B4=1 (BLANK).

= A1=Green, A2=Red, A3=Grey, A4=Black (COLORED). = B1=4 (Green), B2=3 (Red), B3=2 (Grey), B4=1 (Black) (COLORED).

Manually coloring the column will not work here because I want a cell in the second column to be able to match the cell next to it if its color changes. So for instance if a cell in column A changes from "black" to "red", I want the corresponding cell in column B to change from "black" to "red" automatically.

Eg. A1=Green, A2=Red, A3=Grey, A4=Red (COLORED). B1=4 (Green), B2=3 (Red), B3=2 (Grey), B4=1 (Black) (COLORED).

Here A4 is now "red", while B4 is still "black". I want it so that if A4 changes color, B4 will change color to match A4.

I tried experimenting with conditional formatting, but that doesn't seem to be working out so far, would there be a formula for something like this, or am I SOL?

This is possible using Conditional Formatting.
You would have to select both columns and then choose to use a formula for the conditional formatting.

There you would input

=$A1="Red"

and set the formatting to red.

The $ fixes the formula to the first column. If you omit it, only column A would be colored in.

That way you would have to write the cell background color in column A, and if you set the font color to the same value you won't see it...

Another option would be to use a VBA macro, that runs on every SheetChange Event that will copy the background color from column A to column B

Edit:
As @lowak pointed out, you will have to create one rule for each color.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM