If Or Formula Error

stapuff

Well-known Member
Joined
Feb 19, 2004
Messages
1,126
I put the following formula in L1

=IF(J1="",0,IF(OR(K1="T","t"),J1*5000,IF(OR(K1="P","p"),J1*15572,IF(OR(K1="R","r"),J1*20000,0))))


J1 = 1
K1 = r

Result of the formula = #VALUE!

Not usre why.

Stapuff
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try this:

=IF(J1="",0,IF(UPPER(K1)="T",J1*5000,IF(UPPER(K1)="P",J1*15572,IF(UPPER(K1)="R",J1*20000,0))))
 
Upvote 0
BTW, the problem was the structure of your OR clauses.

This is incorrect:
IF(OR(K1="T","t")

This is correct:
IF(OR(K1="T",K1="t")

By making use of the UPPER function, that is not necessary (and shortens the formula a little bit).
 
Upvote 0
=lookup(9.9999999999e+307,choose({1,2},0,vlookup(k1,{"t",5000;"p",15572;"r",20000},2,0)*j1))
 
Upvote 0
Joe4 -

I must of stared at the formula for an hour and to find something as stupid as that.... I appreciate you looking at it. I should have caught that.

Thanks,

stapuff
 
Upvote 0
I must of stared at the formula for an hour and to find something as stupid as that.... I appreciate you looking at it. I should have caught that.
Sometimes, you just need a second set of eyes!:biggrin:
 
Upvote 0
I put the following formula in L1

=IF(J1="",0,IF(OR(K1="T","t"),J1*5000,IF(OR(K1="P","p"),J1*15572,IF(OR(K1="R","r"),J1*20000,0))))


J1 = 1
K1 = r

Result of the formula = #VALUE!

Not usre why.

Stapuff

Somewhat shorter...

=IF(N(J1),J1*CHOOSE(1+(K1="T")+2*(K1="P")+3*(K1="R"),0,5000,15572,20000),0)
 
Upvote 0
Realistically does shorter represent "quicker"?
No, shorter does not necessarily mean "quicker".

But all things considered, Aladin's solutions are usually top-notch and more often than not, I would say that they are usually the "best" solutions.

I have to admit, I don't always understand all the methodology and techniques Aladin uses, though. His knowledge of Excel formulas is far superior to mine.
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,317
Members
452,905
Latest member
deadwings

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