+ Reply to Thread
Results 1 to 5 of 5

Matching partial text to partial text - is this possible?

  1. #1
    Registered User
    Join Date
    09-02-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    2

    Matching partial text to partial text - is this possible?

    I have two columns with text and I want to match, row by row, any word in column A cell to any word in column B cell.

    For example:

    A1: The cat sat on the mat
    B1: I have a dog and a budgie and a cat

    I want a formula in cell C1 which pulls out the word cat as appearing in both A1 and B1, is this possible?

    The real life spread sheet is actually lists of companies and I need to know if they fulfil two criteria however there are variable numbers of companies in each cell and they are often written differently, e.g. A1 = Tesco but B1 = TESCO PLC.

    Any help gratefully received!

    Thanks,
    Samantha

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Matching partial text to partial text - is this possible?

    What happens if you have more than ONE word existing in both sentences, e.g.

    A1: The cat and the dog sat on the mat
    B1: I have a dog and a budgie and a cat

    Im thinking of

    Tesco PLC and TESCO PLC

    Tesco appears in both and so does PLC

    Smith Crisps Ltd and W H Smith Ltd

    Smith and Ltd appear in both

    Or even

    W H Smith Ltd and F W Woolworth

    How would you avoid picking up the W in both names since in this case they are completely different companies?

    UPDATE: I just thought of another one to complicate things

    Tesco PLC and Tesco

    The check should be made backwards, ie Tesco is in Tesco PLC but
    Tesco PLC is not in Tesco
    Last edited by Special-K; 09-02-2015 at 10:46 AM.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Matching partial text to partial text - is this possible?

    From your description I think you will need to use VBA to solve this.

    The SEARCH function will do what you want: the issue is determining the string (word) you want to search for as it would be necessary to find each word in one of the strings (A1) and compare to the second string (B1).

    Using your example ....

    =IF(AND(ISNUMBER(SEARCH("cat",A1)),ISNUMBER(SEARCH("CAT",B1))),"yes","no")

    If cat/CAT is found in both strings, result is YES.

    Plus points made by "Special-K".

  4. #4
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Matching partial text to partial text - is this possible?

    What you're asking for directly is that excel:
    1) Break a text string in A1 up into k text strings where k is the number of space-separated words in the string
    2) Do the same thing breaking B1 into n text strings
    3) Compare each member of string array k to each member of string array n
    4) Return all matches in each member concatenated back together somehow

    That's possible, but I think you'd need to do it in VBA. VBA is slow and string text operations are hard. You'd end up measuring your recalculation time in minutes before long.

    I think you might be better off just using something like SUBSTITUTE(text_string, "PLC", "") to snip out the text string PLC for example, and just nest that a couple times with common instances until you've snipped everything down to the unique bits.

    Long term you should probably try to force standard data entries by either using serial numbers for each company or a standard list that people can pull from using a dropdown for example. That will save on this headache.
    Click the [* Add Reputation] Button to thank people for help!
    Post Attachment: Click [Go Advanced] under the reply box; then click [Manage Attachments] to launch the attachments dialogue.
    Mark Thread Solved: Go to the top of the first post; Select [Thread Tools] dropdown; Pick the [Mark thread as Solved] option.

  5. #5
    Registered User
    Join Date
    09-02-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    2

    Re: Matching partial text to partial text - is this possible?

    Thanks very much guys, I think the VBA would be the only possible option then, how would I go about that?

    If that doesn't work it looks like I'm back to the nightmare situation of checking 3000 rows manually! Although that would probably be just as quick as snipping out all the possible prefixes and suffixes as many of them are listed companies with their unique stock market ticker ID next to them.

    Its a one off research task not a recurring thing thankfully, the data has been sourced from two different commercial information providers so it can't be entered in a uniform way as both have different systems.

+ 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. [SOLVED] Match partial text when partial text is not exact
    By NamiSama in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-21-2014, 07:18 PM
  2. Partial Matching of a text string
    By RapidoDave in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2013, 12:20 PM
  3. [SOLVED] VBA / Macro help needed for matching partial text string
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-21-2013, 09:41 PM
  4. [SOLVED] Matching with partial text
    By grkchakri in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2012, 03:33 PM
  5. Partial Text matching
    By Periya in forum Excel General
    Replies: 0
    Last Post: 08-18-2011, 06:36 AM
  6. Text Matching based on partial text
    By LKluger in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2011, 04:04 PM
  7. matching partial text within one cell to partial text within another
    By Solstice in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 03-03-2010, 09:13 PM

Tags for this Thread

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