UDF Debug?

  • I wrote a UDF to run a calculation for me. One of the variables is "Classification." The function checks the variable Classification and assigns a value to MAQG and MAQL. This works great for every classification....except for the very last one, "Class IIIB." Excel returns #VALUE for some reason and I'm not sure why...Thoughts?






  • Re: UDF Debug?


    I assume that there is only 1 Classification output per use, so would a normal If, ELSEIF, ELSE function not work better?


  • Re: UDF Debug?


    that's a really nice way to clean up the code....but I'm still getting #VALUE!
    I'm sure that I'm using the function right because if I change the cell that Classification is referencing to anything other than "CLASS IIIB" then it works just fine....

  • Re: UDF Debug?


    Hmm strange.. is is possible because your Dim'd them as Integer and 50,600 is outside the limit of what an integer can hold? (Although I though Excel upgraded these to long anyway). Try this instead



    Caleeco

  • Re: UDF Debug?


    Tidied up a little more and now the inconsistencies are showing.


    Caleeco is correct about the Integer Overflow.
    The function Return value is not Typed
    None of the parameters are Typed.
    If the Class is Undefined, the function should exit immedately after the assignment to MAQCheck otherwise it will be assigned a new value in the IF block near the end..


    Revised code, might make the logic easier to understand.


  • Re: UDF Debug?


    Quote from Caleeco;771720

    Hmm strange.. is is possible because your Dim'd them as Integer and 50,600 is outside the limit of what an integer can hold? (Although I though Excel upgraded these to long anyway)...


    That's exactly what the problem was. Thanks

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!