Rounding numbers in microsoft excel

  • Thread starter Thread starter Dell
  • Start date Start date
  • Tags Tags
    Excel Numbers
Click For Summary

Discussion Overview

The discussion revolves around the specific requirements for rounding numbers in Microsoft Excel to two decimal points, with a focus on custom rounding rules based on the digits following the decimal point. Participants explore various methods to achieve this, including built-in functions and user-defined functions.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant outlines a custom rounding requirement where numbers are rounded based on the third decimal place, with specific rules for rounding up or down depending on the value of that digit.
  • Another participant suggests using the cell format to display the desired number of decimal points, but this is challenged as it does not perform the rounding needed for calculations.
  • A participant mentions the ROUND function but notes that it does not meet the custom rounding criteria, particularly for cases where the third decimal is 5.
  • One participant proposes a formula using IF and ROUND functions to achieve the desired rounding behavior for numbers with three decimal places.
  • There is a clarification regarding the example provided, with a participant asserting that the rounding rules were correctly applied, while another initially questioned the example's accuracy.
  • A participant offers to share a user-defined function in VBA to implement the custom rounding rules, indicating they have already developed code for this purpose.

Areas of Agreement / Disagreement

Participants express disagreement on the effectiveness of standard rounding functions in Excel for the specified requirements. There is no consensus on a single solution, as multiple approaches are discussed, including formulas and VBA code.

Contextual Notes

Some participants note limitations in the built-in functions of Excel regarding custom rounding rules, and there is an acknowledgment of the need for clarification on the rounding criteria based on the digits involved.

Dell
Messages
555
Reaction score
0
i need to round numbers in a spreadsheet 2 decimal points, in a way that:

for a number with a.byX

for x>5 i need to round upwards
for x<5 i need to round downwards
for x=5 i need to round up if y is odd and round down if y is even

for example

0.563~0.56
0.566~0.57
0.575~0.58
0.565~0.56

i tried using if, roundup, rounddown, floor,, can't seem to get it right
any ideas
 
Computer science news on Phys.org
Just set the cell format to show the number of digits you want. Setting the precision in the cell format does exactly what you need.
 
no, i need it to round the numbers for me, i need them for calculations and i need them to be exacly the way i stated
 
There is always the ROUND function. You can also do a user defined function.
 
but the round fuction always rounds 5 upwards,
0.5->1
1.5->2
2.5->3
3.5->4...

i need
0.5->0
1.5->2
2.5->2
3.5->4
4.5->4

always rounding to the even number,
only that i need it to the 2nd decimal point no to the whole number
 
As long as you're only dealing with rounding numbers with 3 decimal places down to 2 decimal places, this will work:

=IF((RIGHT(A1,1)<>"5"),ROUND(A1,2),IF(ISODD(A1*100),ROUND(A1,2),TRUNC(A1,2)))

Enter this formula in any cell except A1.
Enter your number in cell A1.

To make this work for other types of numbers, I would write a user defined function in VBA.
 
Dell said:
0.563~0.56
0.566~0.57
0.575~0.58
0.565~0.56

Your example seems to be flawed. Shouldn't 0.566~0.56 , according to your specification?
 
The example's not flawed, the explanation is a bit unclear though.

"b" refers to the 1st digit to the right of the decimal point
"y" refers to the 2nd
"x" refers to the 3rd

His rules state that for "x" > 5, round upward, therefore in 0.566,
"x" is equal to 6 which is greater than 5, so round upward to 0.57
 
I see. sorry. In hindsight I see that it was perfectly explained all along.
 
  • #10
zgozvrm said:
To make this work for other types of numbers, I would write a user defined function in VBA.

I've already written VBA code for this.
Let me know if you're interested.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
23
Views
2K
Replies
3
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 2 ·
Replies
2
Views
2K