+ Reply to Thread
Results 1 to 8 of 8

Index match text query

  1. #1
    Registered User
    Join Date
    05-04-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    10

    Index match text query

    Hi

    I have an excel query and I'd appreciate your help.

    I am trying to extract country names from a string text, and whilst most of my results are correct, there are some anomalies

    If the string has the text 'woman'.. my formula matches 'oman'
    If the string has the text 'indian' .. my formula matches 'india'
    etc.

    I need an exact match and I can't figure out how to do this.

    I attach a sample file.Country formula.xls

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Index match text query

    Put a "space" at the start of each country name in the List of Countries. As long as the FIRST word in the string isn't the country, you'd be good.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Index match text query

    you could include it in the formula
    =INDEX('List of countries'!$B$3:$B$248,MATCH(TRUE,ISNUMBER(SEARCH(" "&'List of countries'!$B$3:$B$248," "&B2)),0))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Registered User
    Join Date
    05-04-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Index match text query

    Thanks both, but I still have a problem where 'Indians' is being matched to 'India' and same for Japanese

    I could put a space after the country name in the list of countries, but some of the text has full stops and commas after the country name, and again these won't match.

    Any more ideas please let me know.

    Many thanks in advance

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Index match text query

    Using your posted workbook...try this
    • Add this item to the top of your country list
    B2: No Match

    • This regular formula returns the name of the stand-alone, embedded country...or No Match, if there are none
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Copy that formula down as far as you need.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Index match text query

    Possibly this

    To keep the formula simple use a dynamic named range

    Name:= "Countries"
    Refers to:=
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Then this array formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Confirm with Ctrl+Shift+Enter not just Enter Before dragging Down.

    Notes
    1/. Yor profile is 2007 but the file provided is 2003, this is for 2007

    2/. Extend the nested SUBSTITUTE() formula if there are more punctuation marks to allow for.

    3/. If there is more than one country in the string the first found in the "Countries" range will be returned
    Attached Files Attached Files
    Last edited by Marcol; 09-05-2013 at 07:28 PM. Reason: Typos
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  7. #7
    Registered User
    Join Date
    05-04-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Index match text query

    Thanks a ton guys. You guys are awesome.

    Problem fixed.

    Marcol - I will make sure my profile is in line with the files that I post in future.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Index match text query

    I've marked this thread as SOLVED for you.
    Next time, select Thread Tools from the links above to mark a thread as SOLVED. Thanks.

+ 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. Index and three match query
    By ajayd3v in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-28-2013, 11:11 AM
  2. Index match query
    By jocer in forum Excel General
    Replies: 3
    Last Post: 07-08-2012, 07:17 AM
  3. Index Match Query
    By leekenkeong in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-03-2012, 10:16 AM
  4. Index & Match query
    By WLM1976 in forum Excel General
    Replies: 12
    Last Post: 12-07-2006, 10:53 AM
  5. [SOLVED] INDEX AND MATCH QUERY ?
    By kate in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-17-2006, 08:25 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