Math within a formula.

Oteshatori

New Member
Joined
Jan 7, 2015
Messages
11
Let's say in B12 I have a number between 1 and 4+.
Now, let's say in cell B16 I want something like: if B12 = 1 then $0, if B12 = 2 then 2*$10, if B12 = 3 then 3*$15, if B12 = 4 then 4*$20, if B12 = greater than 4 then that number *$20.

My head hurts now, but that's the idea. Any thoughts on making such a whacky thing happen?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hey,

perhaps something like

IF(B12<1,0,SWITCH(B12,1,0,2,20,3,45,4,80,B12*20))
 
Upvote 0
Well, one way would be:

Code:
=IF(B12=1,0,IF(B12>=4,B12*20,10+5*(B12-2)))
 
Upvote 0
With this one: =IF(B12=1,0,IF(B12>=4,B12*20,10+5*(B12-2)))

Entering 1 came back with $0 in B16 which is correct.
Entering 2 came back with $10, but it needs to be $10*2 with a return of $20
Entering 3 like above
Entering 4+ came back with the correct answer.

How can we fix 2 and 3?
 
Upvote 0
Entering =IF(B12<1,0,SWITCH(B12,1,0,2,20,3,45,4,80,B12*20))

Came back with
1613782949926.png
 
Upvote 0
Hi,

Here's another way:

Book3.xlsx
BCD
1210
13220
14345
15480
165100
17991980
Sheet780
Cell Formulas
RangeFormula
D12:D17D12=B12*IFERROR(CHOOSE(B12,0,10,15),20)


EDIT: Just made my formula a bit shorter.
 
Last edited:
Upvote 0
Code:
=IF(B12=1,0,IF(B12>=4,B12*20,B12*(10+5*(B12-2))))

PS. You should change your profile to show what version of Excel you're running. SWITCH is available in 365, but if you're running another version you won't have it.
 
Upvote 0
Hi,

Adding another option:

Book3.xlsx
BCDE
12100
1322020
1434545
1548080
165100100
179919801980
Sheet780
Cell Formulas
RangeFormula
D12:D17D12=B12*IFERROR(CHOOSE(B12,0,10,15),20)
E12:E17E12=B12*LOOKUP(B12,{1,2,3,4},{0,10,15,20})
 
Upvote 0
kweaver, you're right I'm on Excel 2016 now.
jtakw, nice approach! I need to be able to put whatever number in B12 for the result in B16, however.
 
Upvote 0

Forum statistics

Threads
1,215,515
Messages
6,125,279
Members
449,220
Latest member
Excel Master

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