View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
egun egun is offline
external usenet poster
 
Posts: 88
Default How do I format a cell based on the contents of a different cell?

Assuming you have a maximum of four possible colors, and ONLY four possible
labels, then conditional formatting should work. Let's say column A will
hold the shaded cells, and column B holds the words "Red", "Amber", "Yellow"
or "Green". First, since conditional formatting only allows three
conditions, you must set all the cells of interest in Column A to a default
color. Let's set them all to green to take care of the "Green" label.

Now, for each of the other colors, set a conditional format that is like the
following:

Cell A2
Select "Format/Conditional Formatting" from the menu
In the drop-down box, select "Formula Is"
In the formula box, type "=IF(B2="Red",1,0)=1"
Click on the "Format..." button and set the fill color to red

Now, click on the "Add..." button and do two more conditional formats for
"Amber" and "Yellow", using the same formula as above.

Finally, select cell A2, copy it to the clipboard, select all the other
cells of interest in column A, select "Paste Special..." and paste the format
from cell A2 into all those other cells. Then see if it works by typing
"Red", "Amber", "Yellow", "Green" into random cells in column B.

HTH,

Eric