ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   rounding to the nearest half ( .5) (https://www.excelbanter.com/excel-programming/337980-rounding-nearest-half-5-a.html)

[email protected]

rounding to the nearest half ( .5)
 
Hi
is it posible to use the rounding to round a calculation to the nearest
half,

ie 2.24 = 2
2.26 = 2.5 etc

Kev

cody

rounding to the nearest half ( .5)
 
Yes it is. In the round function specify the units rounded to after the
value being rounded

(ie FLOOR(B5,.5))


" wrote:

Hi
is it posible to use the rounding to round a calculation to the nearest
half,

ie 2.24 = 2
2.26 = 2.5 etc

Kev


JE McGimpsey

rounding to the nearest half ( .5)
 
One way:

=ROUND(A1*2,0)/2


In article ,
wrote:

Hi
is it posible to use the rounding to round a calculation to the nearest
half,

ie 2.24 = 2
2.26 = 2.5 etc

Kev


Jim Thomlinson[_4_]

rounding to the nearest half ( .5)
 
Here is a user defined function for you. Plce the code in a module and you
are good to go

Public Function RoundNearest(ByVal InputValue As Double, _
ByVal NearestValue As Double) As Double

If Modulo(InputValue, NearestValue) = NearestValue / 2 Then
RoundNearest = (InputValue + NearestValue - (Modulo(InputValue, _
NearestValue)))
Else
RoundNearest = (InputValue - Modulo(InputValue, NearestValue))
End If

End Function


Private Function Modulo(ByVal Number As Double, ByVal Divisor As Double) As
Double
Modulo = Number - Int(Number / Divisor) * Divisor
End Function

You can use it in your spreadsheet like this...

=roundnearest(A1, .5)
--
HTH...

Jim Thomlinson


" wrote:

Hi
is it posible to use the rounding to round a calculation to the nearest
half,

ie 2.24 = 2
2.26 = 2.5 etc

Kev



All times are GMT +1. The time now is 01:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com