multiple "IF" not working as expected

Rhots

Board Regular
Joined
Nov 14, 2006
Messages
100
Hi, it's been a while for me so I need some help

=IF(T3="208Y/120",208,OR(IF(T3="480Y/277",480,OR(IF(T3="240d/120",240)))))


T3 is data validation with a list, the first part works correctly, ie. 208y/120 returns 208, the other 2 return "true" rather than 480 or 240.

Thanks for your help,
Rick
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try getting rid of the OR statements. That is not how you use them. You use OR when you have multiple different values to check for that should return the same single value.

I think you just want:
Code:
[COLOR=#333333]=IF(T3="208Y/120",208,IF(T3="480Y/277",480,IF(T3="240d/120",240)))[/COLOR]
 
Upvote 0
You do not need the ORs
Code:
=IF(T3="208Y/120",208,IF(T3="480Y/277",480,(IF(T3="240d/120",240))))
 
Upvote 0
Do not know if it is "better" but you could also do a Vlookup
Code:
=VLOOKUP(T3,{"208Y/120",208;"480Y/277",480;"240d/120",240},2,0)
 
Upvote 0
It looks like you are just wanting the first 3 characters of the entry in T3.
So why not just:
Code:
=LEFT(T3,3)
 
Upvote 0
With VLOOKUP, you usually have a list that you refer to. You typically see VLOOKUP used when you have a bunch of different options, or allow for inexact matches.
See: https://www.techonthenet.com/excel/formulas/vlookup.php

Note, did you see my last post? If your example is really indicative of the data you are working with, this may be even easier than you think!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top