Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default I want to round Int to quarter

I have a column of numbers: 4.29, 5.79, 6.34, 7.89 and so on

I got a CustomRound function but it doesn't work right. I want to be
able to round the above numbers to the nearest quarter. I suspect that
either I need to use a case statement or more If Then statements. Can
anyone point me in the right direction.

Thank you, Mark

Function CustomRound(pValue As Double) As Double
Dim LWhole As Long
Dim LFraction As Double

'Retrieve integer part of the number
LWhole = Int(pValue)

'Retrieve the franction part of the number
LFraction = pValue - LWhole

If LFraction < 0.5 Then
CustomRound = LWhole
Else
CustomRound = LWhole + 0.5
End If


End Function

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,440
Default I want to round Int to quarter

=MROUND(A1,0.25)

If you get a #NAME error; ToolsAdd-ins, check Analysis Toolpak

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"QUESTION-MARK" wrote in message ps.com...
|I have a column of numbers: 4.29, 5.79, 6.34, 7.89 and so on
|
| I got a CustomRound function but it doesn't work right. I want to be
| able to round the above numbers to the nearest quarter. I suspect that
| either I need to use a case statement or more If Then statements. Can
| anyone point me in the right direction.
|
| Thank you, Mark
|
| Function CustomRound(pValue As Double) As Double
| Dim LWhole As Long
| Dim LFraction As Double
|
| 'Retrieve integer part of the number
| LWhole = Int(pValue)
|
| 'Retrieve the franction part of the number
| LFraction = pValue - LWhole
|
| If LFraction < 0.5 Then
| CustomRound = LWhole
| Else
| CustomRound = LWhole + 0.5
| End If
|
|
| End Function
|


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default I want to round Int to quarter

Mark,

No need for a custom User-Defined-Function.

For a column of numbers starting in cell A2, use a formula like this in another column

=ROUND(A2*4,0)/4

and copy down to match your data. You can replace your original data with the value by using the
pastespecial values feature.

HTH,
Bernie
MS Excel MVP


"QUESTION-MARK" wrote in message
ps.com...
I have a column of numbers: 4.29, 5.79, 6.34, 7.89 and so on

I got a CustomRound function but it doesn't work right. I want to be
able to round the above numbers to the nearest quarter. I suspect that
either I need to use a case statement or more If Then statements. Can
anyone point me in the right direction.

Thank you, Mark

Function CustomRound(pValue As Double) As Double
Dim LWhole As Long
Dim LFraction As Double

'Retrieve integer part of the number
LWhole = Int(pValue)

'Retrieve the franction part of the number
LFraction = pValue - LWhole

If LFraction < 0.5 Then
CustomRound = LWhole
Else
CustomRound = LWhole + 0.5
End If


End Function



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default I want to round Int to quarter

Thank you to everyone who replied!!! Both work great!!

Mark


Bernie Deitrick wrote:
Mark,

No need for a custom User-Defined-Function.

For a column of numbers starting in cell A2, use a formula like this in another column

=ROUND(A2*4,0)/4

and copy down to match your data. You can replace your original data with the value by using the
pastespecial values feature.

HTH,
Bernie
MS Excel MVP


"QUESTION-MARK" wrote in message
ps.com...
I have a column of numbers: 4.29, 5.79, 6.34, 7.89 and so on

I got a CustomRound function but it doesn't work right. I want to be
able to round the above numbers to the nearest quarter. I suspect that
either I need to use a case statement or more If Then statements. Can
anyone point me in the right direction.

Thank you, Mark

Function CustomRound(pValue As Double) As Double
Dim LWhole As Long
Dim LFraction As Double

'Retrieve integer part of the number
LWhole = Int(pValue)

'Retrieve the franction part of the number
LFraction = pValue - LWhole

If LFraction < 0.5 Then
CustomRound = LWhole
Else
CustomRound = LWhole + 0.5
End If


End Function


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 can I round in quarter points? frumious Excel Worksheet Functions 4 July 10th 06 08:46 AM
How do I round time to the nearest quarter of an hour Meghan New Users to Excel 6 July 7th 06 06:36 PM
Need to round the time to the nearest quarter hour. Help John Excel Discussion (Misc queries) 1 February 11th 06 06:41 AM
round numbers to the nearest quarter? LeelooIvy Excel Worksheet Functions 3 May 14th 05 07:34 PM
Round time to nearest quarter hr John Excel Worksheet Functions 2 March 16th 05 09:41 PM


All times are GMT +1. The time now is 08:57 PM.

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"