+ Reply to Thread
Results 1 to 2 of 2

Thread: Rounding Problem in VBA

  1. #1
    Registered User
    Join Date
    01-10-2012
    Location
    India
    MS-Off Ver
    Excel 2008
    Posts
    1

    Question Rounding Problem in VBA

    Dear All,

    I am doing VBA Programming in Excel 2008, i am facing rounding issue in VBA coding, some times its taking rounding up and some times it is taking rounding down, please advise if any one have come across.

    formulae:

    round(tbl.field)+round(tbl.field)

    Thanks in advance

    Regards
    John

  2. #2
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,803

    Re: Rounding Problem in VBA

    from microsoft help
    The Round() function in an Excel spreadsheet uses Arithmetic rounding, which always rounds .5 up (away from 0). The Round() function in Visual Basic for Applications 6, uses Banker's rounding, which rounds .5 either up or down, whichever will result in an even number.
    http://support.microsoft.com/kb/194983
    you could try this which aaron blood posted at ozgrid

    The ROUND formula can be restated as follows:

    =ROUND(x,n)

    =INT((x*10^n)+0.5)/10^n

    The INT method is directly transportable to VBA.
    Last edited by martindwilson; 01-10-2012 at 12:11 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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.2.0