Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

Application.sum overflow?

Latest post Wed, Jun 18 2008 10:35 AM by homt398. 3 replies.
  • Sun, Jun 15 2008 10:13 AM

    • homt398
    • Top 25 Contributor
    • Joined on Tue, Jan 15 2008
    • Peking, China
    • Posts 12
    • Points 167

    Application.sum overflow?

    Why follow code run error: overflow?

    MsgBox Application.WorksheetFunction.Sum(1000 * 33)

    Does any limited to sum function?

    www.officefans.net

    Jonathan Kuo

    Regards

    • Post Points: 21
  • Sun, Jun 15 2008 10:36 AM In reply to

    Re: Application.sum overflow?

    Presumably it uses an intermediary integer storage.

     

    But you don't need sum anyway

     

    MsgBox CLng(1000 * 33)

    Regards

    Bob

    • Post Points: 21
  • Tue, Jun 17 2008 12:09 AM In reply to

    • hrlngrv
    • Top 10 Contributor
    • Joined on Thu, Jan 17 2008
    • somewhere in the western US
    • Posts 67
    • Points 1,055

    Re: Application.sum overflow?

    Bob Phillips:
    Presumably it uses an intermediary integer storage.

    Don't presume, test. From the immediate window,

    ? Typename(100 * 35)
    Integer

    There hasn't been a good reason to default whole numbers to 16-bit integers for nearly 20 years. IIRC, Excel 5, the first version of any of the current Office applications to include VBA, had to run under Windows 3.1 or higher, and Windows 3.1 could only run on 386 or better CPUs, and 386 CPUs are 32-bit chips, VBA should have defaulted to 32-bit integers. But it seems the design whizzes at Microsoft decided to grandfather a good deal of BASICA, er, functionality in VBA.

    FWIW, OpenOffice BASIC automatically promotes 1000 * 35 to Double, but leaves 100 * 35 an integer.

     

     

     

    • Post Points: 21
  • Wed, Jun 18 2008 10:35 AM In reply to

    • homt398
    • Top 25 Contributor
    • Joined on Tue, Jan 15 2008
    • Peking, China
    • Posts 12
    • Points 167

    Re: Application.sum overflow?

    thanks Bob and hrlngrv concern.

    www.officefans.net

    Jonathan Kuo

    Regards

    • Post Points: 5
Page 1 of 1 (4 items) | RSS
Copyright Excel User Group and the relevant contributors, 2008. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.