![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 01:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com