+ Reply to Thread
Results 1 to 7 of 7

Returning value > 32767

  1. #1
    Registered User
    Join Date
    05-16-2008
    Posts
    4

    Returning value > 32767

    Hi all, simple question hopefully...although I can't seem to find an easy answer on the Net. I have one of the simplest user-defined functions on the planet. It takes one variable as input (currency), does some simple math and the return value is also currency. The function works fine until the return value exceeds the 2-byte 32767 limit. I have the return value data type defined to be currency (As Currency) and I also tried (As Long) buut both result in an error when the value exceeds 32767. I have to be missing something very simple. BTW, I'm using Excel2007. Thanks in advance...Mike

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Can you post up the code so I can try it out?

    FYI, declaring a variable as long will result in an integer, so if you are working with fractions of a whole, you should define as double.

    Jason

  3. #3
    Registered User
    Join Date
    05-16-2008
    Posts
    4
    Thanks Jason....function is below. When the input > 3000000, it errs out.

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 05-16-2008 at 04:53 PM.

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Well, you stumped me. Hopefully someone else can help out.

    One thing I would like to mention is using Select Case for multiple If conditions. See below for example:

    Please Login or Register  to view this content.
    Jason

  5. #5
    Registered User
    Join Date
    05-16-2008
    Posts
    4
    Thanks. Yes, I was going to clean up the structure as I have more logic to add anyway but thanks for the example. Hopefully someone else will have some idea why the currency variable is erroneously acting like an Int.

  6. #6
    Registered User
    Join Date
    05-16-2008
    Posts
    4
    Hey Jason, i actually cut and paste in your version and modified it a bit to change the rates and tier maxes into variables, etc. and all of a sudden the thing seems to work! I have no idea why but thanks :-)

  7. #7
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Well, that's great. It wasn't working for me on my PC (it was returning #VALUE!). Glad to hear you got it working.

    Jason

+ 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