+ Reply to Thread
Results 1 to 7 of 7

User Defined Function is static

  1. #1
    Registered User
    Join Date
    03-15-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    User Defined Function is static

    Hello all,

    I am trying to create a function that looks for text in a string, and returns it.
    Example:

    List of Cake types in Column A:
    Cool Cake
    Monster Cake
    Portal Cake

    Strings:
    I love Monster Cake!
    Super Mega Cool Cake is delicious!
    The Portal Cake is a Lie!

    I need the function to return which Cake Type it is based on types listed in column A

    I also need the list of cake types to be updateable, so I have about 15 cells dedicated to Cake Types.

    I currently have this:
    Please Login or Register  to view this content.
    The problem is that I when I add or remove Cake Types, the formula doesn't return the new type even if I save, or close and re-open the book. It will only update if re-enter the formula.

    Basically, Let's say I delete one of the Cake Types from the list. The Function should return "Regular Ol' Cake" since the type no longer exists. However, it just stays the same, even though that type is no longer in the range specified.

    This was kind of a crappy example, so props to whoever can figure this out.
    Last edited by zoudazou; 03-29-2012 at 07:26 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: User Defined Function is static

    Hi

    Can you please attach an example workbook.

    Make sure you include the function code, and an example of it in use.
    rylo

  3. #3
    Registered User
    Join Date
    03-15-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: User Defined Function is static

    Sure thing, thanks!

    Just try to delete anything in the highlighted range, and the function won't reflect the change. It also won't change if you add "Super Cake" to the list.

    Best Regards,
    zoudazou
    Attached Files Attached Files

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: User Defined Function is static

    Your UDF doesn't recalculate because Excel sees no dependency on the data in Macro Sheet.

    UDF notwithstanding, if this the logic?

    Please Login or Register  to view this content.
    The array formula in C2 and copied down is

    =IFERROR(INDEX($A$2:$A$4, MATCH(TRUE, ISNUMBER(SEARCH($A$2:$A$4, B2)), 0)), "Regular ol' cake")
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    03-15-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: User Defined Function is static

    That did it! That's the formula that I needed. When I was attempting Excel's functions, I kept going for an array, I just couldn't find the right combination. :/
    Thanks for your help!

    Just for learning's sake, is there a (somewhat easy) way that I could make the UDF dependent on the data in Macro Sheet? Or is that super complicated?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: User Defined Function is static

    Pass it as a range:

    Please Login or Register  to view this content.
    If its length will vary, use a dynamic range. See http://www.contextures.com/xlnames01.html

  7. #7
    Registered User
    Join Date
    03-15-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: User Defined Function is static

    Awesome! Thanks again for helping me to learn more!

+ 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