+ Reply to Thread
Results 1 to 7 of 7

Calculating the number of matching words between two text cells

  1. #1
    Registered User
    Join Date
    04-10-2017
    Location
    Madrid
    MS-Off Ver
    Office 2016
    Posts
    3

    Calculating the number of matching words between two text cells

    Hi,
    I would need your help to determine the macro to calculate the number of matching words between two cells:
    - A: Text with several keywords separated by "," or ";" or ":" or "."
    - B: Text with several keywords separated by "," or ";" or ":" or "."
    - C: I would like to receive the number of keywords that match in A and B

    Eg:
    A1 = heading keywords 1
    A2 = Environment; Engineering; Environmental Engineering; Climate change; VOC; Waste treatment; Waste disposal

    B1 = heading keywords 2
    B2 = Pollutant; Environment; Geology; Engineering; Waste; Climate change

    C2 = heading matching
    C1 = 5 (Environment; Engineering; Climate Change; Waste) - In this case Waste is contained in two keywords and should count twice -

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Calculating the number of matching words between two text cells

    Hi oppunzano and welcome to the forum,

    I think your A: and B: in your question above are exactly the same. Also, I don't see in C2 where "Waste" shows twice.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    04-10-2017
    Location
    Madrid
    MS-Off Ver
    Office 2016
    Posts
    3

    Re: Calculating the number of matching words between two text cells

    Hi MarvinP,

    Thanks!
    I need to know which of the keywords separated by ; or , or . or any other symbol are included in both cells
    The fact that Waste is alone in B2 but it part of two keywords in A2 should count as partial match twice

    I did not see anything in the forum? Any advice on how to do it?

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Calculating the number of matching words between two text cells

    Hi,

    I don't think there is an answer to this if all the words are in a single cell. If you were to break them out into a cell for each key word (phrase), then I think you might have a chance.

  5. #5
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Calculating the number of matching words between two text cells

    Hi
    its a bit clunky and may be unstable, but this macro seems to work
    it searches for all the words and phrases in cell A2 in the string of text in A3
    if it finds and exact match it counts as full; if the word forms part of a word or phrase in A3 it returns a partial match

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-10-2017
    Location
    Madrid
    MS-Off Ver
    Office 2016
    Posts
    3

    Re: Calculating the number of matching words between two text cells

    Hi NickyC,
    Many thanks for the code! I will run on my table

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,159

    Re: Calculating the number of matching words between two text cells

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. Replies: 21
    Last Post: 10-10-2019, 03:12 AM
  2. Matching words in other cells
    By katri80 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-26-2016, 11:47 AM
  3. [SOLVED] Percentage of matching words between cells
    By papusale in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 04-19-2016, 06:00 AM
  4. How to compare text of same row in two different columns and return matching words?
    By guest2013 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-17-2015, 03:22 PM
  5. drop down, matching and calculating in different cells
    By JoannaDz in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-10-2012, 05:00 PM
  6. [SOLVED] Find matching words in 10 columns and add row numbers of matching words
    By zeke 29 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-03-2012, 09:57 AM
  7. Find matching words of (sheet1)cell in (sheet2) cells.
    By ali84pk in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-28-2010, 01:06 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