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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to combine 3 if or statements in 2003? 1

Status
Not open for further replies.

acevans

Technical User
Apr 9, 2003
78
US
My company has multiple numbered branches in multiple cities and want excel to remind me what city they are in. The first number set is in Conroe and the second is in El Paso. Right now I have them in 2 different cells. Is there a way to combine them in the same cell along with the third statement later ?
This is my first statement

=IF(OR(B3=310,B3=311,B3=506,B3=505,B3=330),"Conroe"," ")

and this is my second statement

=IF(OR(B3=655,B3=656,B3=658,B3=659,B3=667,B3=691,B3=841,B3=858,B3=860,B3=862),"El Paso"," ")

I will make the third later.
 
I would recommend making a lookup table, of branch numbers alongside city. Then a simple VLOOKUP would do what you want.

Otherwise, yes, you can combine statements as you requested, like this:
Code:
=IF(OR(B3=310,B3=311,B3=506,B3=505,B3=330),"Conroe",IF(OR(B3=655,B3=656,B3=658,B3=659,B3=667,B3=691,B3=841,B3=858,B3=860,B3=862),"El Paso"," "))


Cheers, Glenn.

Beauty is in the eye of the beerholder.
 
Thank you so much for your quick respons! I was able to add the third section to and it works perfect!
 
I'd just like to reiterate Glenn's first suggestion: Have a simple lookup table with the ID# in one column and the corresponding Branch name in an adjacent column.

Then you can just use something like:
[tab]=VLookup(A2, rngLookupTable, 2, False)
to return the Branch Name.


[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
2 Answers

1) you can nest up to 7 If statements in 2003

2) Vlookup is a better solution (easier to Manage, New codes added Easily)

Vlookup example
Have a sheet named X-Ref-City with the following data

310 Conroe
311 Conroe
330 Conroe
505 Conroe
506 Conroe
655 El Paso
656 El Paso
658 El Paso
659 El Paso
667 El Paso
691 El Paso
841 El Paso
858 El Paso
860 El Paso
862 El Paso

Formula = VLOOKUP(B3,'X-Ref-City'!$A$1:$B$20,2,FALSE)


*******************************************************
Occam's Razor - All things being equal, the simplest solution is the right one.
 
Since we are talking about already resolved questions:

You can have as many if statements as you like by combining them as follows:

=IF(OR(B3=310,B3=311,B3=506,B3=505,B3=330),"Conroe","")&IF(OR(B3=655,B3=656,B3=658,B3=659,B3=667,B3=691,B3=841,B3=858,B3=860,B3=862),"El Paso","")&IF(OR(B3=755,B3=756,B3=758,B3=759,B3=767,B3=791),"Huntsville","")


A man has only two choices: He can be right or he can be happy.
 
xlhelp said:
You can have as many if statements as you like...
[pedant]

Up to a limit of 1,024 characters in Excel 2003, or 8,192 characters in 2007

[/pedant]

[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
anotherhiggins said:
[pedant]
Up to a limit of 1,024 characters in Excel 2003, or 8,192 characters in 2007
[/pedant]
[Obfuscator]

In that case you could always insert Name (eg Conroe) and define a formula, such as =IF(OR(Sheet1!B3=310,Sheet1!B3=311,Sheet1!B3=506,Sheet1!B3=505,Sheet1!B3=330),"Conroe","") and so on.

[/Obfuscator]

Please don't use words I don't understand even after looking up in the dictionary [rofl]

A man has only two choices: He can be right or he can be happy.
 



...or a perambulating Formicidae. But aren't they all, rhetorically speaking?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top