+ Reply to Thread
Results 1 to 15 of 15

Using Search and Lookup/Match/Index Functions

  1. #1
    Registered User
    Join Date
    01-06-2009
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2013
    Posts
    11

    Using Search and Lookup/Match/Index Functions

    Hello everyone,

    I have a challenging question. I am trying to lookup for a specific word / phrase inside an excel cell then return a value of 1,2 or 3.
    I was able to use the Search function alone, but was not able to combine it with either a Lookup / Match / Index function.
    Can someone please help. I have attached a sample file to illustrate my issue.

    Thanks so much!
    Lucas
    Attached Files Attached Files

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: Using Search and Lookup/Match/Index Functions

    This seems to do the trick =IFERROR(LOOKUP(9,999E+307;SEARCH($E$4:$E$15;A2);$F$4:$F$15);"-")

    Thre is one difference on row 6. Working on it

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Using Search and Lookup/Match/Index Functions

    Use this array formula

    =IFERROR(INDEX($F$1:$F$12,MIN(IF(ISNUMBER(SEARCH($E$1:$E$12,A1)),ROW($E$1:$E$12),99))),".")

  4. #4
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Using Search and Lookup/Match/Index Functions

    Quote Originally Posted by Pepe Le Mokko View Post
    This seems to do the trick =IFERROR(LOOKUP(9,999E+307;SEARCH($E$4:$E$15;A2);$F$4:$F$15);"-")

    Thre is one difference on row 6. Working on it
    The problem is Pepe that row contains demerge and the list contains merge and demerge, so your Search has two matches, demerge is at character 47, merge at 49, and doing a lookup of a big number against it matches the 49, so it matches the merge not demerge, hence 2.

  5. #5
    Registered User
    Join Date
    01-06-2009
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2013
    Posts
    11

    Re: Using Search and Lookup/Match/Index Functions

    Hi Bob and Pepe, thanks for your help!

    Bob, I tried your formula but it does not work on my side.
    Basically, if the cell is blank or if the cell has "This company has been delisted on dd/mm/yyyy", I'd like to get "."
    If there is a reason for the delisting (e.g., in liquidation), I'd like to see the corresponding number which is "1" in this case.

    I've attached a revised file to make it more clear. Thanks!
    Attached Files Attached Files

  6. #6
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Using Search and Lookup/Match/Index Functions

    Try this..

    I think it can't be done with excel formulas..

    I think a vba code will do..

    Please Login or Register  to view this content.
    Don't forget to click *
    Last edited by Vikas_Gautam; 08-06-2014 at 12:06 PM.

  7. #7
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Using Search and Lookup/Match/Index Functions

    Quote Originally Posted by fl9805 View Post
    Bob, I tried your formula but it does not work on my side. !
    It is an array formula, which means Control-Shift-Enter, not just Enter.

  8. #8
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Using Search and Lookup/Match/Index Functions

    Here's the adjusted formula to your new layout

    =IFERROR(INDEX($F$4:$F$15,MIN(IF(ISNUMBER(SEARCH($E$4:$E$15,A2)),ROW($E$4:$E$15)-ROW($E$4)+1,99))),".")

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Using Search and Lookup/Match/Index Functions

    Quote Originally Posted by Bob Phillips View Post
    The problem is Pepe that row contains demerge and the list contains merge and demerge, so your Search has two matches, demerge is at character 47, merge at 49, and doing a lookup of a big number against it matches the 49, so it matches the merge not demerge, hence 2.
    But so would your solution fail if a particular row contained e.g. "Takeover (hostile)" and the (sorted) table contained both "Takeover" and "Takeover (hostile)".

    True, that is not an issue with the current choice of keywords, but in general the point stands...

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  10. #10
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Using Search and Lookup/Match/Index Functions

    Quote Originally Posted by XOR LX View Post
    But so would your solution fail if a particular row contained e.g. "Takeover (hostile)" and the (sorted) table contained both "Takeover" and "Takeover (hostile)".

    True, that is not an issue with the current choice of keywords, but in general the point stands...

    Regards
    Nobody suggested otherwise, indeed if you reverse the order of merger and demerger in the lookup table, mine fails and Pepe's works. I was just explaining to Pepe why his had failed, I did not expect to be critiqued for helping out.

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Using Search and Lookup/Match/Index Functions

    Quote Originally Posted by Bob Phillips View Post
    Nobody suggested otherwise, indeed if you reverse the order of merger and demerger in the lookup table, mine fails and Pepe's works. I was just explaining to Pepe why his had failed, I did not expect to be critiqued for helping out.
    But why is your comment to Pepe "helping out", yet mine to you a "critique"?

    On the contrary, I was doing just as you did to Pepe: pointing out how your solution may fail, given a different dataset. Surely that is as much "helping" you in terms of your offered solution as you "helped" Pepe in terms of his?

    One of the things I personally feel it is our obligation to try to do - as Forum Experts/Gurus - is to attempt to always give the most generalisable solution possible, and not, for example, one which works, but only by virtue of the current data being convenient so as to make it so.

    A solution should take into account that that data may change, should it not?

    Regards
    Last edited by XOR LX; 08-06-2014 at 05:04 AM.

  12. #12
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Using Search and Lookup/Match/Index Functions

    The difference is, I offered a solution, I don't recall seeing yours. So let's see your ... most generalisable solution

  13. #13
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Using Search and Lookup/Match/Index Functions

    Quote Originally Posted by Bob Phillips View Post
    The difference is, I offered a solution, I don't recall seeing yours. So let's see your ... most generalisable solution
    I'm sorry that my comment on your solution has obviously offended you. But I really don't think there's any need for such a sarcastic, argumentative response.

    Besides, one should be free to offer comments/suggestions on other people's solutions without necessarily having to trump them.

    Regards

  14. #14
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Using Search and Lookup/Match/Index Functions

    =IFERROR(INDEX($F$4:$F$15,MATCH(TRUE,INDEX((COUNTIF($A2,"*"&$E$4:$E$15&"*")<>0),0),0)),".")
    Try this formula in "C2" and copy towards down
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  15. #15
    Registered User
    Join Date
    01-06-2009
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2013
    Posts
    11

    Re: Using Search and Lookup/Match/Index Functions

    Thanks so much Bob, Siva, Pepe, Vikas and XOR.

    Bob's formula and as well as that of Siva works!
    You guys are amazing. Thanks a million!

+ 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. UDF Lookup function as an alternative to array functions & match/index
    By Andrew_Harris in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-15-2012, 09:34 PM
  2. LOOKUP, MATCH, INDEX Question. (2 Search Values)
    By J00 in forum Excel General
    Replies: 1
    Last Post: 07-16-2012, 03:51 PM
  3. Confused Search or Match Lookup or index
    By grouchmax in forum Excel General
    Replies: 10
    Last Post: 01-28-2011, 12:26 PM
  4. Replies: 2
    Last Post: 12-10-2010, 11:39 AM
  5. Replies: 14
    Last Post: 04-27-2010, 01:20 AM

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