+ Reply to Thread
Results 1 to 3 of 3

rounding

  1. #1

    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. #2
    K Dales
    Guest

    RE: rounding

    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
    >
    >


  3. #3
    Dave Peterson
    Guest

    Re: 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



    [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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1