Nested conditional statements

G

gcotterl

I've having difficulty following what parts of a formula are triggered
if the result of each IF statement is "true" or "false".

Can someone please provide an example of a formula containing several
conditional (i.e., IF) statements and then describe how the formula
works?
 
H

Harlan Grove

gcotterl said:
I've having difficulty following what parts of a formula are triggered
if the result of each IF statement is "true" or "false".
....

Excel evaluates formulas left to right, so the first condition
satisfied produces the result. For example, if cell X99 evaluates to
2.25, the formula

=IF(X99<=0,
"black",
IF(X99<=1,
IF(X99<=0.5,
"gray",
"white"
),
IF(X99<=2,
IF(X99<=1.5,
"pink",
"red"
),
IF(X99<=3,
IF(X99<=2.5,
"purple",
"blue"
),...

The first 3 IF conditions aren't satisfied, but the 4th is (X99<=3).
The 5th condition is also satisfied (X99<=2.5), so the return value is
"purple". Had X99 evaluated to 2.8, the 4th condition would still have
been satisfied, but the 5th wouldn't have been, so the return value
would have been "blue".

Even if further out in the formula there were a condition X99=2.25, it
wouldn't determine the return value because the pair of conditions
X99<=3 and X99<=2.5 were satisfied first.

See if your Tools menu contains the command Tools > Formula Auditing >
Evaluate Formula. If it does, it'll step through how Excel evaluates
your formulas.
 
S

Shane Devenshire

Hi,

Please put your questions into the body of the post. It causes problems in
some web browsers.

In Excel 2003 you can do 7 levels of nesting and in 2007 64. In the
spreadsheet the basic form is

=IF(A1>10,5,IF(A1>5,2,0))

You might post exactly what you are trying to do because nested IF's may not
be the appropriate or best solution.
 

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