Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2003
    Posts
    17

    Red face Unanswered: RoundUp / RoundDown in VBA ?

    Hello,

    Are there equivalent functions for RoundUp RoundDown in VBA ?
    On the cell if I put RoundDown(1234, -1) it gives me 1230
    but I could not find a function to achieve this while writing this in a macro.
    Do I need to do any inclusion ?
    It gives "Sub or Function not defined" error for RoundDown on compilation.

    For the time being, I wrote a dummy function to do the RoundDown as it was very urgent.

    Also the Round function behaves diffently in VBA. It does not accept a negative num_digits parameter. i.e. Round(1234, -1) fails in VBA but works as "RoundDown" in the xls.

    Is there no way to achieve RoundDown in VBA ??

    Regards,

    Parag

  2. #2
    Join Date
    Mar 2004
    Location
    Fort Worth, Texas, USA
    Posts
    68
    Application.WorksheetFunction.RoundDown(1234, -1)

  3. #3
    Join Date
    Mar 2004
    Location
    Adelaide, Australia
    Posts
    32

    Smile a little clarification

    What actuary is trying to say is that you can use excel functions in vba by using the WorksheetFunction property of the Application object.

    In vba explorer, goto the the Object Browser (menu View - Object Browser (or F2)). Go through the classes until you find WorksheetFunction, then you will see all the members of it in the right hand pane. see attachment.

    HTH.
    Attached Thumbnails Attached Thumbnails objbrowser.jpg  
    Regards,
    Rod.

    Programmer response #5 - "Even though it doesn't work, how does it feel?"

  4. #4
    Join Date
    Oct 2003
    Posts
    17

    Smile

    Thank you for the detailed reply.
    It is very interesting, I had never used WorksheetFunction in VBA.
    That's great.
    Thanks again.

  5. #5
    Join Date
    Jul 2008
    Posts
    1
    How do I use Roundup function in VBA for Access 2007

Posting Permissions

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