Find closest matches to string within the same column using vba

andnand

Board Regular
Joined
Apr 18, 2008
Messages
53
Office Version
  1. 365
Platform
  1. Windows
Hi everyone, hope you are safe and healthy!!

I would like to hear ideas and or code to find and write matches. I have a column with hundreds to thousands of rows of data and would like to find the closest matches within the same column to normalize the list.

finding matches.xlsx
L
2Original
3John Doe
4John F Doe
5John Frank Doe Robbins
6John Frand Doe
7John D Doe R
8John F. Doe
9John Doe
10Doe, John
Start


Desired output:

finding matches.xlsx
LMNO
2OriginalProposed 1Proposed 2Proposed 3
3John DoeJohn DoeJohn F. DoeJohn Frank Doe Robbins
4John F DoeJohn DoeJohn F. DoeJohn Frank Doe Robbins
5John Frank Doe RobbinsJohn DoeJohn F. DoeJohn Frank Doe Robbins
6John Frand DoeJohn DoeJohn F. DoeJohn Frank Doe Robbins
7John D Doe RJohn DoeJohn F. DoeJohn Frank Doe Robbins
8John F. DoeJohn DoeJohn F. DoeJohn Frank Doe Robbins
9John DoeJohn DoeJohn F. DoeJohn Frank Doe Robbins
10Doe, JohnJohn DoeJohn F. DoeJohn Frank Doe Robbins
Start


To consider:
- Showing above only related strings, column has hundreds/thousands in random order
- Most of the values have more than 1 string within the cell
- ","(commas)
- "."(points)
- " "(single spaces)
- " "(multiple spaces or other)

It might be easier to get the following output based on shorter and longer matches....:

finding matches.xlsx
LMO
2OriginalProposed 1Proposed 3
3John DoeJohn DoeJohn Frank Doe Robbins
4John F DoeJohn DoeJohn Frank Doe Robbins
5John Frank Doe RobbinsJohn DoeJohn Frank Doe Robbins
6John Frand DoeJohn DoeJohn Frank Doe Robbins
7John D Doe RJohn DoeJohn Frank Doe Robbins
8John F. DoeJohn DoeJohn Frank Doe Robbins
9John DoeJohn DoeJohn Frank Doe Robbins
10Doe, JohnJohn DoeJohn Frank Doe Robbins
Start


Thank you, and have a great and safe weekend!!!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi Koen,

Thank you for the suggestion but I need to automate the task using vba....

Cheers,

Andrew
 
Upvote 0
Hi Koen,

Thank you for the suggestion but I need to automate the task using vba....

Cheers,

Andrew
Hi Andrew,
you forgot to add your efforts writing that code so far (this forum is not a free coding service but full of enthusiastic volunteers that can help you). Searching for "VBA fuzzy lookup" gets you e.g. this code Excel VBA module for fuzzy lookup (via Levenshtein distance) for a person id by first name and last name in a person range that has first, last, full and id fields. which can be helpful.
Koen
 
Upvote 0
Hi Koen,

I was looking for guidance because my efforts didn't pay off. I simply clean up, replacing " " "," & "." helped a lot but then you have tons with strings at the end and strings in the middle. Even when I tried to replace the characters it took forever, selecting the column and replacing will replace everywhere and creating a simple cell by cell but that took forever so I ended up copying the range to an array and clean the elements of the array and pasting them back to the range...

I have seen the link you recommended above, is too complicated for my level...

Thank you and please let me know if there is some other guidance I can follow.
 
Upvote 0

Forum statistics

Threads
1,224,621
Messages
6,179,937
Members
452,949
Latest member
beartooth91

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