Rounding options in a formula

Caly

Board Regular
Joined
Jul 19, 2015
Messages
160
Office Version
  1. 365
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
Hi I have multiple dollar value ranges and am trying to apply one formula for each option but is there a better way to write the formula below?

=if(and(A2>10,000,A2<100,000),roundup(A2,-4),
if(and(A2>100,000,A2<1,000,000),roundup(A2,-5),
if(and(A2>1,000,000,A2<1,000,000,000),roundup(A2,-6),
Roundup(A2,-7))))

Column A - Dollars
$12,036,219.22
$437,379.70
$11,737.18
$180,595.28
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
try this:
Excel Formula:
=ROUNDUP(A2,-INT(LOG10(A2)))
 
Upvote 0
Solution
Thank you. That works great. Just one thing for the first number $12,036,219.22, I want it to say $13,000,000 but it is coming out to $20,000,000. Is there a way for it to return that?
 
Upvote 0
If it's an exception only for that range ($12,036,219.22 to $13,000,000) then this should work:
=ROUNDUP(A2,IF(-INT(LOG10(A2))=-7,-6,-INT(LOG10(A2))))
 
Upvote 0
Thank you. Wow that worked perfectly.

Is this the accurate way of understanding the formula logic. Is it saying to roundup to the nearest 6 digits where the next whole number is 7 characters and then if taht is not true then the last statement will bring it to the next whole number?
 
Upvote 0
Yes I think so. The IF function adds the one exception that you need (otherwise it calculates as per original solution). By the way, the solution from offthelip is amazing! Thanks for the question Caly!
 
Upvote 0
Yes awesome- thank you both so much. This worked perfectly. Appreciate the help and support.
 
Upvote 0
You could also use this formula:
=ROUNDUP(A2,INDEX({0;-1;-2;-3;-4;-5;-6;-6},MATCH(-INT(LOG10($A2)),{0;-1;-2;-3;-4;-5;-6;-7},0)))
It's flexible if you end up with more exceptions (note the 2nd "-6" in the INDEX part accommodates your current exception).
 
Upvote 0
an even shorter way of doing that is:
Excel Formula:
=ROUNDUP(A2,-MIN(6,INT(LOG10(A2))))
 
Upvote 0
Thank you both - this works perfect and I was able to use in multiple projects thank you
 
Upvote 0

Forum statistics

Threads
1,223,840
Messages
6,174,960
Members
452,593
Latest member
Jason5710

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