• Rounding in a function (A2000)

    Author
    Topic
    #360018

    How would I round this expression to 2 decimal places? fMatch = ((curYTDE + curCE) * 0.03) – curYTDM

    Viewing 2 reply threads
    Author
    Replies
    • #541091

      Thanks Chris, that works for me, too.

    • #541097

      I don’t think using CLng will work. I would use the function below as follows:

      fMatch = gfRound2( ((curYTDE + curCE) * 0.03) – curYTDM)

      However, you might want to round prior to the subtraction, depending on your situation.

      Public Function gfRound2(ByRef RawData) As Currency
        ' This function rounds the "RawData" input to 2 decimal places.
        gfRound2 = CCur(CCur(RawData) / 100) * 100
      End Function
      
    • #541145

      Try this:

      fMatch = Round(((curYTDE + curCE) * 0.03) – curYTDM,2)

      There wasn’t a built-in round function in earlier versions, but there is in 2000. Just be aware that it doesn’t work like the Excel rounding functions. This one only rounds up if the determinant is greater than 5.

      • #541212

        Thanks, Charlotte, that was what I was looking for!

    Viewing 2 reply threads
    Reply To: Rounding in a function (A2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: