Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combine multiple IF statements in Excel 3

Status
Not open for further replies.

Celeste025

Technical User
Mar 6, 2003
73
0
0
US
I am trying to write a formula for Excel 97 that will combine multiple IF statements in one line.. what I have so far is:

=IF(B1=1,E1)

I need it to continue to say something like:

ELSEIF(B1=2,E2), ELSEIF(B1=3,E3), ELSEIF(B1=4,E4), ELSEIF(B1=5,E5) etc etc... but elseif isnt working. Ive done it before but cant remember how now...

Thanks!
 
=if(B1=2,E2,if(B1=3,E3,if(B1=4,E4,if(B1=5,E5,if(B1=6,E6)))))
KEEP IN MIND THOUGH YOU CAN ONLY HAVE 7 NESTED IF'S

Regards,

Wray
 
Of course, if what you are doing is really that relationship based on the contents of B1 (1=E1, 2=E2, 3=E3, etc.) then you could use the INDIRECT function like this:
[blue]
Code:
   =INDIRECT("E"&B1)
[/color]


 
Wray,

Thank you very much, the nested If statement worked beautifully!

Celeste
 
Wray,
Is 7 nested IF's a hard limit, or is controllable by some environment setting (somewhat like recently used files list)?
 
Krinid,

As far as I know 7 nested IF's is a hard limit. Really ifyou have more than that you probally would be better off makin a table of your data and using VLOOKUP

Regards,

Wray
 
I thought Zathras idea was spot on. It helped me learn so Zathras you get a star :)
 
Wray69,
I agree, more than 7 IF's and there's probably a better way. Most of the time I've seen people nest >3 IF statements, it's b/c that's the only way they knew how to do it, despite better/shorter methods being available.
Didn't know there was a limit, though! I probably won't ever nest that many myself, but it's good bit of knowledge to know in case I come across it. Thanks.
 
You can get around the NESTED limit by not nesting...
=IF(A1=1,2,"")&if(A1=2,3,"")&if(A1=3,4,"")etc etc ad nauseum

Rgds
Geoff
Si hoc legere scis, nimis eruditionis habes
Get the best answers to your questions - faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top