If statement result appearing in different colors

  • Thread starter Thread starter WGD
  • Start date Start date
W

WGD

Is there a way to write an IF statement where the text will change color
depending on the result? eg

=if(x=0,"RED-colored text","BLACK-colored text") where 'RED-colored text'
would appear in RED, etc

Thank You!
WayneD
 
Take a look at Format|Conditional formatting.

Is there a way to write an IF statement where the text will change color
depending on the result? eg

=if(x=0,"RED-colored text","BLACK-colored text") where 'RED-colored text'
would appear in RED, etc

Thank You!
WayneD
 
Hi Wayne

Try Conditional Formatting.
Mark the range of cells where you want this formatting to be applied
Format>Conditional Formatting>use dropdown for Formula is> enter
=$A$1=0 >Format>select Red Font

In the case, A1 is the equivalent of your "X"
The formula given, fixes it to be cell A1 in all cases.
If you make it $A1, then it will be relative, and will depend what is in
column A for the row where the text appears.
 
Not being the brightess bulb on the block, I am missing something from the
reply.
How do I apply the conditional formatting function to an IF statement?

Best,
Wayne Dengel
 
Wayne,

Try this quick example to see if it helps you understand what Roger suggested:

In a new worksheet, enter 0 in A1, 1 in A2, and 2 in A3.
In B1 enter =IF(A1=0,TRUE,FALSE) and copy it down to B3.

Now your sheet should look like this:
0 TRUE
1 FALSE
2 FALSE

Highlight column B and go to Format -> Conditional Formatting...
In the drop-down for Condition 1, change the selection from "Cell Value Is" to "Formula Is"
Now type =$A1=0 in the next box and click Format
Select RED from the color palette then click ok until you are back to your spreadsheet.

Now your sheet should look like this:
0 TRUE
1 FALSE
2 FALSE

It's a pretty simple example, but you can do tons with it. Hope it helps!!
 
How about using the help in Excel and lookup conditional formatting then
apply the method Roger gave you
 
You don't apply the conditional formatting to the formula. You apply it to the
cell.

Select your cell
Click on the Home Tab
Then click on the conditional formatting icon
Choose manage rules at the bottom of that dropdown

Start adding as many rules as you want.
(one for the "then" result and one for the "else" result)

Equal to: (whatever)
and give it a nice format.

Add another rule
Equal to: (whatever2)
and give it a nice format.
 
Got it. Thank You. Procedure to get there minutely different (w/2007 version).

Wayne Dengel

"KimCo" <KCostalesATourcoopDOTcomNOSPAM> wrote in message Wayne,

Try this quick example to see if it helps you understand what Roger suggested:

In a new worksheet, enter 0 in A1, 1 in A2, and 2 in A3.
In B1 enter =IF(A1=0,TRUE,FALSE) and copy it down to B3.

Now your sheet should look like this:
0 TRUE
1 FALSE
2 FALSE

Highlight column B and go to Format -> Conditional Formatting...
In the drop-down for Condition 1, change the selection from "Cell Value Is" to "Formula Is"
Now type =$A1=0 in the next box and click Format
Select RED from the color palette then click ok until you are back to your spreadsheet.

Now your sheet should look like this:
0 TRUE
1 FALSE
2 FALSE

It's a pretty simple example, but you can do tons with it. Hope it helps!!
 
Back
Top