Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I round time down to the nearest half hour? KatJ Excel Worksheet Functions 4 April 3rd 23 07:32 PM
Rounding Date to Next Half Year frrrrrr Excel Discussion (Misc queries) 3 July 17th 08 08:34 PM
I need a formula with rounding up & rounding down to the nearest . Tony Kay Excel Worksheet Functions 3 May 29th 07 11:13 PM
correct to the nearest half soorya New Users to Excel 2 April 8th 07 02:01 PM
how do i round time to the nearest half a minute ALEX Excel Discussion (Misc queries) 3 September 25th 06 11:25 PM


All times are GMT +1. The time now is 09:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"