+ Reply to Thread
Results 1 to 4 of 4

Custom Function Returns #num error

  1. #1
    Registered User
    Join Date
    04-24-2006
    Posts
    12

    Custom Function Returns #num error

    (A9) 68000
    (A10) 85000
    (B10) 29
    (c10) =MPG(A9,A10,B10)
    ******************************************************
    Function MPG(StartMiles As Integer, FinishMiles As Integer, Gallons As Integer)
    MPG = (FinishMiles - StartMiles) / Gallons
    End Function
    ******************************************************
    Why does this return a #num error in C10?

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    jyellis

    Integer variables are stored as 16-bit (2-byte) numbers ranging in value from -32,768 to 32,767

    cells A9 & A10 are larger than 32767

    Try changing Inerger to Long

    Long (long integer) variables are stored as signed 32-bit (4-byte) numbers ranging in value from -2,147,483,648 to 2,147,483,647.

  3. #3
    Registered User
    Join Date
    04-24-2006
    Posts
    12

    THANKS!!!! I missed that

    Thanks!!!!!

  4. #4
    Doug Glancy
    Guest

    Re: Custom Function Returns #num error

    jyellis

    Declare them as longs, not integers, and it should work.

    hth,

    Doug

    "jyellis" <[email protected]> wrote in
    message news:[email protected]...
    >
    > (A9) 68000
    > (A10) 85000
    > (B10) 29
    > (c10) =MPG(A9,A10,B10)
    > ******************************************************
    > Function MPG(StartMiles As Integer, FinishMiles As Integer, Gallons As
    > Integer)
    > MPG = (FinishMiles - StartMiles) / Gallons
    > End Function
    > ******************************************************
    > Why does this return a #num error in C10?
    >
    >
    > --
    > jyellis
    > ------------------------------------------------------------------------
    > jyellis's Profile:
    > http://www.excelforum.com/member.php...o&userid=33803
    > View this thread: http://www.excelforum.com/showthread...hreadid=535743
    >




+ 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