Correct Syntax for Changing Color of Cell Based on Value

W

W

I have a column with percentages in it, and I want to have the color of each
cell change based on values. If the percentage is greater than 50 then I
want Blue. If the percentage is 25 to 50 I want red. If the Percentage
is less than 25 I want black. I guessed at the following syntax for a
Custom number type, but Excel is rejecting this:

[Blue][>50]Percentage;[Red][>25]Percentage; Percentage

What would be the correct syntax?

A further refinement on this is that I don't want more than one tenth of one
percent precision, so the template would be 00.0%.
 
D

Dave Peterson

Maybe something like:
[Blue][>0.5]0.00%;[Red][>0.25]0.00%;0.00%

(notice that the numbers are now decimals--not whole numbers.)

I have a column with percentages in it, and I want to have the color of each
cell change based on values. If the percentage is greater than 50 then I
want Blue. If the percentage is 25 to 50 I want red. If the Percentage
is less than 25 I want black. I guessed at the following syntax for a
Custom number type, but Excel is rejecting this:

[Blue][>50]Percentage;[Red][>25]Percentage; Percentage

What would be the correct syntax?

A further refinement on this is that I don't want more than one tenth of one
percent precision, so the template would be 00.0%.
 
D

Dave Peterson

: [Blue][>0.5]0.0%;[Red][>0.25]0.0%;0.0%

(I didn't notice the last sentence of your original post.)

I have a column with percentages in it, and I want to have the color of each
cell change based on values. If the percentage is greater than 50 then I
want Blue. If the percentage is 25 to 50 I want red. If the Percentage
is less than 25 I want black. I guessed at the following syntax for a
Custom number type, but Excel is rejecting this:

[Blue][>50]Percentage;[Red][>25]Percentage; Percentage

What would be the correct syntax?

A further refinement on this is that I don't want more than one tenth of one
percent precision, so the template would be 00.0%.
 
T

T. Valko

Use conditional formatting.

In Excel versions 2003 and before:

Select the range of cells you want to format. Assume this range is A1:A10.
Goto the menu Format>Conditional Formatting
Use the Formula Is option
Condition 1
Formula Is: =A1>0.5
Click the Format button
Select the Font tab
Set the color to BLUE
OK
Click the Add button
Condition 2
Formula Is: =A1>=0.25
Click the Format button
Select the Font tab
Set the color to RED
OK out
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top