+ Reply to Thread
Results 1 to 3 of 3

UDF returning values AND status

  1. #1
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    178

    UDF returning values AND status

    I have written a UDF in which, given a string (ie:"DDD-MM-SS"), it returns a decimal equivalent. the UDF allows the user to use various delimiters other than dashes and the UDF evaluates variations within the
    input string to determine if a decimal equivalent can be computed without ambiguity.

    Sometimes the variations are unacceptable and hence the string can not be converted into a decimal equivalent. In other cases the variation can be dealt with by making a reasonable interpretation and then continuing to derive a decimal equivalent.

    For these latter two cases, I would like to inform the user calling the UDF that the string was not processed or was processed but with an interpretation.

    The aspect of this question that makes it interesting is that I might be using the UDF within a call by another UDF. ie" UDF1 (argument1) wherein argument 1 is itself a UDF (ie: UDF2).

    Perhaps I am asking too much. If I want status, then that condition might imply that I can not nest my UDF

    If I have to accept that condition, then the next question is how do I convey the status?

    In this situation, I have an input string, and output number of type double, and an output status conveying
    string was not processed or string was processed but an interpretation was made to derive an answer.

    how do i create and convey such status in such a manner that the flow of data is minimally thottled. for example, a MsgBox would stop the processing flow until the user performed an action to allow action to continue. I do not want that.

    Another thought is that I write another UDF to assess the acceptability of a string for further processing.
    That UDF would only have to assess strings from an outside source (ie: worksheet) as I could ensure that
    all my code always returns strings in a valid format and hence would not need checking before use.

    please offer your thoughts on how you might address this situation.

    Thank you
    bil

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,826

    Re: UDF returning values AND status

    I might be tempted to make my UDF output an array (which means selecting multiple cells and confirming with ctrl-shift-enter like other array formulas). Something like
    Please Login or Register  to view this content.
    Note that a 1D array like this will output to Excel as a horizontal array, so you would select a 1 row x 2 column block of cells to enter the formula. You can also use the INDEX() function to return one result or the other =INDEX(myudf1("ddd-mm-ss"),1) to return the result, for example.

    It's not clear to me if udf1 is the outer function or the inner function when the functions are nested together. If the array udf above is always the outer function, then it should not need any further changes. If the array udf above may be the inner function, then the outer function needs to be able to handle the array input. This could be done directly in the outer udf's code. You could also use the INDEX() function to select the appropriate part of the inner udf's output to input to the outer udf. =UDF1(INDEX(UDF2("ddd-mm-ss"),1))

    I'm pretty sure that isn't the only way to do this, but it is one possible approach. I am optimistic that, one way or another, you should be able to accomplish what you want.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    178

    Re: UDF returning values AND status

    I am interested in your approach! You opened up my mind. Wow. thank you.
    the key is INDEX....as I can use it to display status or not depending on the situation.

    Thank you, once again, Shorty! Mighty Tall answer for me. One I want.

    Respectfully,
    bil

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Unique values status bar
    By anthoj92 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2017, 06:46 PM
  2. Macro to Track Prospect Status and Date of Status Change
    By zainfidel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-24-2016, 02:16 PM
  3. Replies: 3
    Last Post: 09-11-2014, 04:32 PM
  4. arrange data to show different billing status and customer status
    By applesandpears in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 11-29-2012, 05:57 PM
  5. Replies: 4
    Last Post: 04-08-2012, 09:43 PM
  6. Replies: 1
    Last Post: 06-01-2006, 01:15 PM
  7. returning a sheet to blank orginal status?
    By Mile029 in forum Excel General
    Replies: 2
    Last Post: 07-13-2005, 03:28 PM

Tags for this Thread

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