Complicated ROUNDUP / ROUNDDOWN issue

Fishboy

Well-known Member
Joined
Feb 13, 2015
Messages
4,267
Hi All,

In my latest Excel 2010 workbook I have the following formula:

=IF(L13=0,0,IF(F13="Standard",L13,IF(F13="50%",(LEFT(L13,FIND(" ",L13&" ")-1)/2&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),IF(F13="x2",(LEFT(L13,FIND(" ",L13&" ")-1)*2&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),IF(F13="x3",(LEFT(L13,FIND(" ",L13&" ")-1)*3&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),"None")))))

It is basically looking for a rule in F13 and applying it to L13. Now, L13 contains a number, a space then a word which is why I have the LEFT and RIGHT parts in there. The "Standard", "x2", "x3" and "None" rules are all working great. So far so good. I then run into issues with the "50%" rule where the value is divided by 2.

My problem is if the divided number results in a decimal less than 1 I need it to ROUNDUP, but if the divided number results in a decimal above 1, I need to ROUNDDOWN. As you can imagine the inclusion of text in this cell is making life complicated and I am unsure how to go about adding this caveat into my formula.

Anyone out there got a any clever suggestions that may help me out here please?
 
Sorry, i think i put one of the brackets in wrong! Try

=IF(L13=0,0,IF(F13="Standard",L13,IF(F13="50%",(MAX(1,FLOOR(LEFT(L13,FIND(" ",L13&" ")-1)/2,1))&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),IF(F13="x2",(LEFT(L13,FIND(" ",L13&" ")-1)*2&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),IF(F13="x3",(LEFT(L13,FIND(" ",L13&" ")-1)*3&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),"None")))))
Aha! This is spot on mate. Many thanks for your help.
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Just a wild shot: how about always using ROUNDDOWN and use MAX for a minimum result of 1, like
Code:
... MAX(1,ROUNDDOWN( ...
This might work, depending on your data.
Thanks Marcel, although I ended up using gaz_chop's solution I still wanted to show my appreciation for your advice.
 
Upvote 0
Just one thing I noticed, the "50%" won't work properly as it is text, try changing it to just 50%, like

=IF(L13=0,0,IF(F13="Standard",L13,IF(F13=50%,(MAX(1,FLOOR(LEFT(L13,FIND(" ",L13&" ")-1)/2,1))&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),IF(F13="x2",(LEFT(L13,FIND(" ",L13&" ")-1)*2&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),IF(F13="x3",(LEFT(L13,FIND(" ",L13&" ")-1)*3&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),"None")))))
 
Upvote 0
Just one thing I noticed, the "50%" won't work properly as it is text, try changing it to just 50%, like

=IF(L13=0,0,IF(F13="Standard",L13,IF(F13=50%,(MAX(1,FLOOR(LEFT(L13,FIND(" ",L13&" ")-1)/2,1))&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),IF(F13="x2",(LEFT(L13,FIND(" ",L13&" ")-1)*2&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),IF(F13="x3",(LEFT(L13,FIND(" ",L13&" ")-1)*3&" "&RIGHT(L13,LEN(L13)-FIND(" ",L13))),"None")))))
Hi gaz,

Actually the "50%" as text is not an issue as the IF statement relating to it is only checking this value is TRUE before dividing L13 by 2. The divide by 2 rule is exactly that, unaffected by percentage. If I remove the quotation marks from around the 50% the formula stops working.
 
Upvote 0
Hi gaz,

Actually the "50%" as text is not an issue as the IF statement relating to it is only checking this value is TRUE before dividing L13 by 2. The divide by 2 rule is exactly that, unaffected by percentage. If I remove the quotation marks from around the 50% the formula stops working.

Ah your value in F13 must be text, I entered it as .5 (50%) and it wouldn't work.

As long as it works .......

Gaz
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,728
Members
449,465
Latest member
TAKLAM

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