#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default rounding

Hi, Iv assigned a value in vba to MyValue, Can somebody advise how I
round this up if the decimal is 0.5 or above, or down if below 0.5.
Regards Robert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default rounding

MyRoundedValue=Round(MyValue,0)
--
- K Dales


" wrote:

Hi, Iv assigned a value in vba to MyValue, Can somebody advise how I
round this up if the decimal is 0.5 or above, or down if below 0.5.
Regards Robert


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default rounding

VBA's Round (added in xl2k) works differently from Excel's =Round().

You may want to stick with Excel's:

Option Explicit
Sub testme()

Dim myValue As Double
Dim iCtr As Long

For iCtr = 1 To 4
myValue = iCtr + 0.5
MsgBox "myValue=" & myValue & _
vbLf & "Round=" & Round(myValue, 0) & _
vbLf & "Application.Round=" & Application.Round(myValue, 0)
Next iCtr

End Sub



wrote:

Hi, Iv assigned a value in vba to MyValue, Can somebody advise how I
round this up if the decimal is 0.5 or above, or down if below 0.5.
Regards Robert


--

Dave Peterson
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
ROUNDING FORMULA =ROUND(B12/$B$10,1) ROUNDING TO HIGH SunshineinFt.Myers[_2_] Excel Worksheet Functions 7 March 5th 09 06:41 PM
Rounding up @ 3 instead of 5 keith Excel Worksheet Functions 4 June 24th 08 03:09 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
Rounding EC Excel Worksheet Functions 6 December 10th 06 12:27 PM
Worksheet rounding vs VBA rounding Simon Cleal Excel Programming 4 September 2nd 05 01:50 AM


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

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

About Us

"It's about Microsoft Excel"