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
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
MyRoundedValue=Round(MyValue,0)
--
- K Dales
"[email protected]" 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
>
>
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
[email protected] 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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks