+ Reply to Thread
Results 1 to 7 of 7

Search A Cell And Output A Result From An Array

  1. #1
    Registered User
    Join Date
    05-27-2008
    Posts
    28

    Search A Cell And Output A Result From An Array

    Is there a way to create a function that would search a cell for an array of text strings, if it found one of them it would output the corresponding result from a different array of text strings?

    Example:
    Cell A1: "bag 4 c"
    Array 1: "1","2","3","4"
    Array 2: "small", "medium", "large", "extra large"
    Formula: IF(A1 contains {"1","2","3","4"}, display {"small", "medium", "large", "extra large"}, 0)
    Result: extra large

    I think a combination of the IF, SEARCH and LOOKUP functions might accomplish this. Any ideas?

  2. #2
    Valued Forum Contributor khamilton's Avatar
    Join Date
    10-08-2009
    Location
    IL
    MS-Off Ver
    Excel 2007
    Posts
    345

    Re: Search A Cell And Output A Result From An Array

    enter this with control+shift+enter
    Please Login or Register  to view this content.
    Please acknowledge the response you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

  3. #3
    Registered User
    Join Date
    05-27-2008
    Posts
    28

    Re: Search A Cell And Output A Result From An Array

    Wow, that is an impressive formula, and it works great, +reputation! The only thing is that I over simplified my example a bit because I am not always trying to look up numbers, and sometimes the order of the information is not consistent or some information is absent, in which case the formula breaks down. Here is a better example:

    A1: SHORTS SM BLK
    A2: CAP YEL
    A3: GLOVE BLU LG

    In column B I would like to display the size (where SM=Small, MD=Medium, LG=Large, XL=Extra Large) and in column C I would like to display the color (where BLK=Black, WHT=White, YEL=Yellow, BLU=Blue). The forumula needs to find the right text string in the cell and output its corresponding value. I'm sure the same formula could be used in both cases just with modified constraints. What do you think?

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Search A Cell And Output A Result From An Array

    Try this formula in B1

    =LOOKUP(2^15,SEARCH({"SM","MD","LG","XL"},A1),{"Small","Medium","Large","Extra Large"})

    or simpler to name the lists and use

    =LOOKUP(2^15,SEARCH(AbSizes,A1),Sizes)

    That'll give an error if none of those are found. If you have Excel 2007 use IFERROR to return a blank

    =IFERROR(LOOKUP(2^15,SEARCH(AbSizes,A1),Sizes),"")
    Audere est facere

  5. #5
    Registered User
    Join Date
    05-27-2008
    Posts
    28

    Re: Search A Cell And Output A Result From An Array

    Yep, that does the trick. Thank you a ton.

    Question: How do you create a referencable list exactly? I think that would be useful.

    Also, what does the 2^15 signify? For curiosity's sake.

    Edit: I have Excel 2010
    Last edited by JonnyBoy333; 09-30-2011 at 04:24 PM.

  6. #6
    Valued Forum Contributor khamilton's Avatar
    Join Date
    10-08-2009
    Location
    IL
    MS-Off Ver
    Excel 2007
    Posts
    345

    Re: Search A Cell And Output A Result From An Array

    2^15 is one more than the maximum number of characters you can enter in a cell, so it will search the cell and account for the entire number of characters. HTH

  7. #7
    Registered User
    Join Date
    03-19-2010
    Location
    Sarajevo
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Search A Cell And Output A Result From An Array

    Hello can someone help me pls.
    Here is idea:
    i need to get a value from table but i need to use vlookup and hlookup at once.
    Pls download the following xls table.
    http://www.megaupload.com/?d=5IMMZ2MD
    In the sheet 'Calculate', in columns A and B are the input data; in columns D and E are data that I need to get from sheet 'table';

    I was doing before with commands IF and VLOOKUP (if b=15 than vlookup...; if B=20;vlookup ... and so on)
    but now i have planty columns to do on that way

+ 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