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?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
When you say "decimal less than 1" do you mean 1 decimal place? Maybe post a couple of examples showing the results you expect.
 
Upvote 0
When you say "decimal less than 1" do you mean 1 decimal place? Maybe post a couple of examples showing the results you expect.
Hi gaz_chops, thanks for your response. To clarify what I meant by "decimal less that 1" was a result of 0.1 to 0.9. I have included a grab of what I am working on below:


Excel 2010
BCDEFGHIJKLMN
6
7Encounter Level:L16Roll OutcomeLoot RuleRaw Loot OutcomeModified Loot Outcome
8L16CoinsRangeL16CoinsRuleL16CoinsOutcome
9Coins:x3371d12 1,000 gp5000 gp15000 gp
10L16GoodsRangeL16GoodsRuleL16GoodsOutcome
11Goods:None634d6 Gems17 GemsNone
12L16ItemsRangeL16ItemsRuleL16ItemsOutcome
13Items:50%841d3 Medium1 Medium0.5 Medium
14
Generator


In the above example the formula is getting the rule from F13.
It is applying the rule to L13.
The output of this rule is in N13.

This is the formula in N13:

=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")))))

Currently N13 is showing as "0.5 Medium" - which I would like to ROUNDUP to "1 Medium"
If however N13 was showing a decimal answer greater than 1 (i.e "1.1 Medium" or higher), I need this to ROUNDDOWN to "1 Medium"

So to recap, 0.1 to 0.9 needs to ROUNDUP and include the word from the end.
1.1 and above needs to ROUNDDOWN and include the word from the end.

I am sorry if this isnt making any sense, if so just let me know and I will try and rephrase the request into something easier to understand.
 
Last edited:
Upvote 0
As an example is this correct

Code:
[TABLE="width: 130"]
<tbody>[TR]
[TD="width: 65, align: right"]0.5[/TD]
[TD="width: 65, align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]0.7[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]0.9[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]1.1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]1.5[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]1.7[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]1.9[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]2.2[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]2.7[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: right"]3.25[/TD]
[TD="align: right"]3[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
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.
 
Upvote 0
Similar idea

=MAX(1,FLOOR(A1,1))

=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
As an example is this correct

Code:
[TABLE="width: 130"]
<tbody>[TR]
[TD="width: 65, align: right"]0.5[/TD]
[TD="width: 65, align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]0.7[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]0.9[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]1.1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]1.5[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]1.7[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]1.9[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]2.2[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]2.7[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: right"]3.25[/TD]
[TD="align: right"]3[/TD]
[/TR]
</tbody>[/TABLE]
Hi again gaz, the above table is correctly handling the decimals, yes.
 
Upvote 0
Similar idea

=MAX(1,FLOOR(A1,1))

=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")))))
I have just tried replacing my formula with the bold part from the quote above, however I get the following error when I press enter:

"The formula you typed contains an error. For help...yadda yadda yadda"

I didn't know what the =MAX(1,FLOOR(A1,1)) was or where it would go. Was I wrong to only use the bottom part of your post?
 
Upvote 0
I have just tried replacing my formula with the bold part from the quote above, however I get the following error when I press enter:

"The formula you typed contains an error. For help...yadda yadda yadda"

I didn't know what the =MAX(1,FLOOR(A1,1)) was or where it would go. Was I wrong to only use the bottom part of your post?

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")))))
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

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