Help Find Closest match in Long Text Strings

maximillianrg

Board Regular
Joined
Aug 7, 2014
Messages
74
Office Version
  1. 2016
Platform
  1. Windows
Hello Excel Masters

Thank you in advance for your help. I'm looking for a formula that can compare a text string like the one in cell A5 below to thousands of text strings and return the closest match. In the below, the formula would compare cell A5 against cells A1-A3 and because cell A2 is the closest match it would return the value in cell B2 (Pear). I have tried variations of vlookup and in most cases it picks up the first or last but not the best match.




AB
1The Quick BrownApple
2The Quick Brown Fox JumpsPear
3The Quick Brown FoxBanana
4
5The quick brown fox jumps over the lazy dog?????
6
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Is the version of Excel in your profile up to date?...Excel 2016? I ask because Microsoft created an add-in for fuzzy matching, but it is designed for Excel 365:
I needed to dial the "similarity threshold" down to about 0.25 before the algorithm would choose "Pear" for the 1st phrase (it returned a blank when a higher threshold was set). To use it, one set of information is used as a lookup table...and a formal Excel table is created from it. The other data for which you want a match is also converted to a table. The fuzzy match add-in then allows you to specify the relationships between various columns of the two tables and to adjust the similarity threshold. Results are returned in a separate table:
MrExcel_20220603.xlsx
ABCDE
1PhraseReturnTextShortsReturn
2The quick brown fox jumps over the lazy dogThe Quick BrownApple
3Brown fox jumpsThe Quick Brown Fox JumpsPear
4The brown boxThe Quick Brown FoxBanana
5
6
7PhraseReturnSimilarity
8The quick brown fox jumps over the lazy dogPear0.8476
9Brown fox jumpsPear0.9200
10The brown boxBanana0.8020
Sheet13

If you don't have 365, you might investigate using Power Query, as it too has a fuzzy match capability and it is part of Excel 2016.
 
Upvote 0
Book1
AB
1PhraseReturn
2The Quick BrownApple
3The Quick Brown Fox JumpsPear
4The Quick Brown FoxBanana
5
6
7PhraseReturn
8The quick brown fox jumps over the lazy dogPear
Sheet1
Cell Formulas
RangeFormula
B8B8=LOOKUP(2,1/(LEN(SUBSTITUTE(LOWER(A8),LOWER($A$2:$A$4),""))=AGGREGATE(15,6,LEN(SUBSTITUTE(LOWER(A8),LOWER($A$2:$A$4),"")),1)),$B$2:$B$4)
 
Upvote 0

Forum statistics

Threads
1,214,869
Messages
6,122,012
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top