Output based on a code

Muthukrishnan V

Active Member
Joined
May 29, 2008
Messages
297
Office Version
  1. 365
Platform
  1. Windows
Microsoft Excel 2007. Cell C5 contains amount in numerical. Cell D5 contains a code number either 1 or 2 in numerical.
Cell E5 and F5 contain formulas to give interest based on C5 (similar formulas but with different interest rate).

My request: Cell G5 should give output: Amount in numerical. If D5 is 1, then formula based on E5. If D5 is 2, then formula based on F5. Kindly furnish me a formula to do this. Thanks.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You format would be structured like this:

=IF(D5=1,your formula based on E5,IF(D5=2,your formula based on F5,what to return if D5 is not 1 or 2))
So you would replace the red parts with the appropriate formulas, and the blue part with whatever should happen if D5 is not 1 or 2.
 
Upvote 0
=IF(D5=1,IF(C5<=300000,0,IF(C5<=500000,(C5-300000)*5%-MIN((C5-300000)*5%,10000),IF

(C5<=1000000,10000+(C5-500000)*20%,110000+(C5-1000000)*30%))),IF(D5=2,IF(C5<=250000,0,IF
(C5<=500000,(C5-250000)*5%-MIN((C5-250000)*5%,12500),IF(C5<=1000000,12500+(C5-500000)
*20%,112500+(C5-1000000)*30%))),0)

Shows error Sir. Anything wrong in ths formula. Sorry for trouble. Request help. I will copy the solution and paste. Thank you Sir.
 
Upvote 0
It looks like you have unbalanced parentheses. You have 18 "(", but only 17 ")", so you are missing a ")" somewhere.
That is always the first thing you want to check. If you do not have the same number of "(" as ")", your formula will always error.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
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