Rounding up different numbers in Excel - excel

I'm in need of a formula that rounds numbers differently depending on if the number is tens, hundreds, thousands, hundred-thousands, millions, etc. I know the basic rounding functions in Excel but not sure how to do this exactly.
Examples:
1 - 999 need to be rounded up to the nearest 10.
1.000 - 99.999 need to be rounded up to the nearest 100.
100.000 - 999.999 need to be rounded up to the nearest 1.000.
1.000.000 - 999.999.999 need to be rounded up to the nearest 100.000.
1.000.000.000 - 999.999.999.999 need to be rounded up to the nearest 1.000.000
And all this in single formula that can easily be copied down.
Any help would be greatly appreciated!

You can use ROUNDUP function with a LOOKUP function nested to give you the logic you need, i.e. with values in A2 down use this formula in B2 copied down
=ROUNDUP(A2,LOOKUP(A2,10^{0,3,5,6,9},-{1,2,3,5,6}))
This part
10^{0,3,5,6,9}
defines the lower bound of each range. And this part:
-{1,2,3,5,6}
gives the number of digits to round to, e.g. -2 gives next 100, -3 next 1000 etc.
This rounds up to the nearest multiple of 100 etc. so 134 will round to 140. If you want to round to the nearest multiple then you can use the exact same formula but with ROUND in place of ROUNDUP

Probably the best way to do it would be a custom VBA function switching between values - That would give you the most amount of control, but you could do it with nested IF() statements too:
=IF(A1<1000,CEILING(A1,10),IF(A1<100000,CEILING(A1,100),IF(A1<1000000,CEILING(A1,1000),IF(A1<1000000000,CEILING(A1,100000),CEILING(A1,1000000)))))
Hope that helps!!

Related

Use MS Excel to round one number to 2 significant figures, then update another cell to match the number of decimal places

I am trying to use Microsoft Excel to format a large set of data. The data is all in decimal format and the results are paired so that we have 2 values per record. The first value is a Mass in grams, and the second value is the Uncertainty of that mass also in grams.
For example:
SampleName = S1, Mass(g) = 28.695, Uncertainty(g) = 1.601133
What I need to do is have the "Uncertainty" update to 2 significant figures, then depending on the value returned, have the "Mass" update to match the number of decimal places (or whole numbers) that the "Uncertainty" now is.
e.g.
if Uncertainty became 1.6, then Mass should become 28.6
if Uncertainty became 1.61, then Mass should become 28.69
if Uncertainty became 2, then Mass should become 29
I have attempted to use the ROUND function on the "Uncertainty" cell but then I don't know how to make the "Mass" cell update accordingly.
I have tried the following 2 ROUND formulas, which both seem to work for rounding the "Uncertainty":
=ROUND(A1,2-INT(LOG(ABS(A1))))
=ROUND(A1, 2)
Any help would be much appreciated.
This formula counts the number of decimal places in a given cell:
=LEN(RIGHT(A1,LEN(A1)-FIND(".",A1)))
So you could use this in your Round formula where you specify the number of decimals:
=ROUND(A1, LEN(RIGHT(A1,LEN(A1)-FIND(".",A1))))
To round to 2 significant figures you can use something like this:
=ROUND(uncertainty,2-(1+INT(LOG10(ABS(number)))))
To round (eg) B2 based on number of decimals in (eg) D2:
=ROUND(B2,IFERROR(LEN(RIGHT(D2,LEN(D2)-FIND(".",D2))),0))

Excel remove Characters past a decimal

I have a large excel file the contains many way-points in Latitude and Longitude in the degree and minutes. My problem is that the numbers can't be rounded and must stay exactly the same, but the last 2 numbers need to be removed (in most cases)
I was wondering if there is a formula that would only allow three characters past the decimal. This is how most my numbers look.
26° 17.82964
However Sometimes they look like this
26° 9.82
I know I can format the cell as a number and set the decimal place to 3, however when I copy and paste it doesn't stay the same.
This formula will truncate (It does not Round) the numbers and give all if less:
=MID(A1,1,FIND(".",A1)+3)
This formula will round, but it will always fill out the numbers to three decimal places (I am aware the OP did not want rounding, this is for others that may want it.):
=LEFT(A1,FIND(" ",A1))&TEXT(ROUND(--MID(A1,FIND(" ",A1),LEN(A1)),3),"0.000")

Excel roundings not summing properly

I have a excel sheet with a few formulas like this:
A1,A2,A3= 0.13,1.25,2.21
A4: =(A1*A2) =0.16 ( 2 decimal points)
A5: =(A2*A3) =2.76 ( 2 decimal points)
A6: =SUM(A4;A5) =2.93 ( 2 decimal points )
And i want to show 0.16+2.76=2.92
well, there's my problem in bold. i want to add the values from the cells, not the formuls result. How can i do that ? Thank you
Presumably you're working with money which is why you need this.
One way to resolve this is to use =ROUND(A1*A2, 2) etc. and base your subsequent calculations from that.
Do be aware though that you will still occasionally get spurious results due to Excel using a 64 bit IEEE754 floating point double to represent numbers. (Although it does have some extremely clever circumvention techniques - see how it evaluates 1/3 + 1/3 + 1/3 - it will not resolve every possible oddity). If you're building an accounting-style sheet you are best off working in pence, and dividing the final result.
Round the values before you sum, ie:
=ROUND(A1*A2,2)
=ROUND(A2*A3,2)
You could wrap your formulas with the ROUND function:
=ROUND(A1*A2,2)
This will give you 0.16 as opposed to 0.163. Do this for each of your calculations and you'll only be calculating everything to two decimal places. Although I'm not sure why you'd want to do that.

Round up decimals to fractional multiple

I am trying to round up decimals to specific values in the following way:
1. 12.12 ---> 12.25
2. 12.5 ---> 12.5
3. 12.59 ---> 12.75
4. 12.75 ---> 12.75
5. 12.77 ---> 13
So they should be rounded up to the decimals .25, .5 and .75 or integer.
Is there an Excel function which can do this?
Please try:
=ROUNDUP(4*A1,0)/4
Your question uses positive numbers for sample data but there is a primary difference involving how negative numbers are handled by the CEILING function and the ROUNDUP function that should be mentioned.
This has to do with the way that ROUNDUP rounds away from zero and CEILING rounds to the numerically larger¹ number
          
The formulas in C2:D2 are:
=CEILING(A2, 0.25) ◄ C2
=ROUNDUP(A2*4, 0)/4 ◄ D2
Note the differences in the 7th, 9th and 11th rows. This is the difference in how the two functions handle rounding negative numbers. If you wanted the results in column C to follow the values in column D, you would have to use the following for negative numbers.
=CEILING(A2, -0.25) ◄ C2
But that doesn't work properly on positive numbers. While you could write a conditional statement that changed the sign of the significance parameter, it's a lot easier to choose what you want to happen with negative numbers and use either CEILING or ROUNDUP as the case may be.
¹If you get several mathematicians in a room and ask them if -1 is higher, larger or greater than -2, you will start World War III so I'm not going down that rabbit hole. The differences between CEILING and ROUNDUP are probably intended to cover both sides of the argument.
All of this can be related to the ROUNDDOWN function and the FLOOR function as well.
If you are only rounding to a fractional significance and not rounding in one direction or another, the MROUND function is another possibility.

Is there any function / formula available in MS-Excel which can give between CEILING and FLOOR?

I am looking for a function which can provide me between of CEILING and FLOOR.
For example, If the number is 20.67 it should give me 21 and if the number is 20.33 it should give me 20.
There are thousands rows of data I have and I cannot apply different methods on different columns, like FLOOR on one column and CEILING on other.
Is there anything available which can work out?
Thanks
ROUND() - tell it to round to 0 digits, e.g.:
=ROUND(11.54,0)
will show 12, but
=ROUND(11.44,0)
will show 11.
Yep, simply use round. The 2nd arugment would always be 0 in your case
=ROUND(cell_ref,0)

Resources