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

Nested If

Status
Not open for further replies.

CNeeds

Programmer
Mar 24, 2004
111
US
If try to get a excel formula with the days of week and I cannot figure it out.

=A1 Value (Sun)
=B15 Value 10
=B16 Value 15
=B17 Value 20
=B18 Value 30
=B19 Value 35
=B20 Value 50
=B21 Value 55

(Nested If?) Formula Wanted:
If A1=Sun Then B15
If A1=Mon Then B16
If A1=Tues Then B17
If A1=Wed Then B18
If A1=Thurs Then B19
If A1=Fri Then B20
If A1=Sat Then B21

Thanks!!!!!

 
=IF(A1="Sun",B15,IF(A1="Mon",B16,IF(A1="Tue",B17,IF(A1="Wed",B18,IF(A1="Thu",B19,IF(A1="Fri",B20,IF(A1="Sat",B21,"Bad Data")))))))

 
This will allow you to dispense will the data in cells B15:B21 if you wish

=CHOOSE(MATCH(A1,{"Sun","Mon","Tue","Wed","Thu","Fri","Sat"},0),10,15,20,30,35,50,55)

or if you don't then how about

=INDEX($B$15:$B$21,MATCH(A1,{"Sun","Mon","Tue","Wed","Thu","Fri","Sat"},0))

Regards
Ken.........

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 
User defined function with SELECT...CASE statement.

Much easier. Much easier to deal with variations in text case as well.
 
Much easier to deal with variations in text case as well.

What do you mean?

CNeeds, Nested IFs are bulky, but they are great learning tools! :)

I think Excel users should learn to read them and write them as soon as possible.



 


Hi,

Set up a Table in a15:B21

[tt]
Sun 10
Mon 20
Tue 25
Wed 30
Thu 40
Fri 45
Sat 55
[/tt]
[tt]
=index(B15:B21,match(a1,A15:A21,0),1)

or

=vlookup(A1,A15:b21,2,false)
[/tt]

Skip,

[glasses] [red]Be Advised![/red] For those this winter, caught in Arctic-like calamity, be consoled...
Many are cold, but few are frozen![tongue]
 
A UDF in place of native Excel functionality? - Completely unncessary and inefficient!! Native functionality will always be far more efficient than code.

Regards
Ken.............

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 
2nd that - lookup tables is the easiest to maintain going forwards. UDFs are a last resort
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top