+ Reply to Thread
Results 1 to 8 of 8

Search for text in strings using arrays

  1. #1
    Registered User
    Join Date
    11-06-2012
    Location
    Brisbane, Austalia
    MS-Off Ver
    Excel 2010
    Posts
    21

    Search for text in strings using arrays

    Hello,
    I want to look at a column of data, check if the cell contains text that matches any of the values in another column, if so, return the value in the adjacent column. Sounds easy but I am banging my head against the desk now!
    Workbook attached.
    Elements.xlsx

    Many thanks,

    DWSF
    Last edited by dwsf; 11-19-2015 at 01:50 AM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Search for text in strings using arrays

    See if this will help?
    =INDEX(B:B,MATCH(LEFT(E2,FIND("_",E2,1)-1)&"*",A:A,0))
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Search for text in strings using arrays

    Hello,

    try in F2 and copy down:

    =IF(COUNTIF(E:E,A2&"*"),TRUE)

    Edit: sorry, misread the question, just looked at the spreadsheet with FALSE as the result.

    cheers, teylyn

  4. #4
    Registered User
    Join Date
    11-06-2012
    Location
    Brisbane, Austalia
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Search for text in strings using arrays

    thanks fdibbins, this works great, but what if there is no "_" character in the string. Am I barking up the wrong tree with the "search" or "find" functions?
    Thanks again,
    dwsf

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Search for text in strings using arrays

    If there is no _ then what else would delimit the text...the 1st space?
    If so, then we could maybe replace all _ with space, then search on that?

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Search for text in strings using arrays

    In F2:

    =IFERROR(LOOKUP(2,1/SEARCH($A$2:$A$119,E2,1),$B$2:$B$119),"no match")

    searching "Barium" at first position of "Barium_F (ug/L)"

    Remove ,1 if searching "Barium" within "XXX Barium_F (ug/L) XXX"
    Quang PT

  7. #7
    Registered User
    Join Date
    11-06-2012
    Location
    Brisbane, Austalia
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Search for text in strings using arrays

    I was trying to get something working using arrays. I have had a lot of success in the past using {=e.g.median(if(array x) = somevalue, (array y), 0) } to parse multiple values but I cant get the syntax to work with search or find, which is what I thought was the way forward because these dont depend on breaking up the cell text based on a particular character.
    Cheers,
    dwsf

  8. #8
    Registered User
    Join Date
    11-06-2012
    Location
    Brisbane, Austalia
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Search for text in strings using arrays

    Thanks bebo!

+ 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. Search Comments for Multiple Text Strings
    By jham808 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-20-2015, 09:53 AM
  2. Search For Multiple Text Strings
    By jham808 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-19-2015, 12:53 PM
  3. [SOLVED] Trying to search for list of strings using Arrays,Scripting Dictionary or FileSystemObject
    By downtown1933 in forum Excel Programming / VBA / Macros
    Replies: 42
    Last Post: 10-01-2013, 04:38 AM
  4. Truncate text strings using LEFT and FIND/SEARCH for multiple search terms
    By ngdoherty in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-17-2013, 07:51 PM
  5. Search for multiple text strings
    By SueWithQuestion in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-10-2011, 09:48 AM
  6. search for multiple text strings?
    By pbgvdad in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-03-2008, 04:37 PM
  7. Keyword Search on Strings of Text
    By odie82 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-25-2007, 08:00 PM

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