# Rounding options in a formula

#### Caly

##### Board Regular
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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

#### offthelip

##### Well-known Member
try this:
Excel Formula:
``=ROUNDUP(A2,-INT(LOG10(A2)))``

#### Caly

##### Board Regular
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?

##### New Member
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))))

#### Caly

##### Board Regular
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?

##### New Member
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!

#### Caly

##### Board Regular
Yes awesome- thank you both so much. This worked perfectly. Appreciate the help and support.

##### New Member
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).

#### offthelip

##### Well-known Member
an even shorter way of doing that is:
Excel Formula:
``=ROUNDUP(A2,-MIN(6,INT(LOG10(A2))))``

#### Caly

##### Board Regular
Thank you both - this works perfect and I was able to use in multiple projects thank you

Replies
4
Views
196
Replies
3
Views
158
Replies
0
Views
74
Replies
3
Views
86
Replies
4
Views
147

1,186,168
Messages
5,956,341
Members
438,247
Latest member
UZev

### 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.

### Which adblocker are you using?

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

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