Fuzzy Matching - new version plus explanation

al_b_cnu

Well-known Member
Joined
Jul 18, 2003
Messages
4,546
It has been a while since I originally posted my Fuzzy matching UDF’s on the board, and several variants have appeared subsequently.

I thought it time to ‘put the record straight’ & post a definitive version which contains slightly more efficient code, and better matching algorithms, so here it is.

Firstly, I must state that the Fuzzy matching algorithms are very CPU hungry, and should be used sparingly. If for instance you require to lookup a match for a string which starts with, contains or ends with a specified value, this can be performed far more efficiently using the MATCH function:
Fuzzy Examples.xls
ABCDE
1Starts WithEndsContains
2BilljelenBill
3Mr Bill Jelen433
4Bill Jelen
5Joe Bloggs
6Fred Smith
MATCH Example


... Continued ...
 
Hey, thanks for reply. I will try and let you know in case I get any success with that.
Any thoughts on which algorithm to in case of lead / trailing spaces or how to remove them? (I have tried all the trimming)
 
Upvote 0

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hey, thanks for reply. I will try and let you know in case I get any success with that.
Any thoughts on which algorithm to in case of lead / trailing spaces or how to remove them? (I have tried all the trimming)
The function I posted above removes ALL characters except 0 to 9, a to z (and their equivalents). Any alphabetics are converted to lower case so ABCD will match 100% with abcd.
 
Upvote 0
Hi Rochak,
In view of the number of rows that the code would have to trawl through, almost certainly a bespoke macro would be more efficient, and it could give you a progress report whilst it's computing.
Can you post a sample of the worksheet layout?
 
Upvote 0
Hi Alan,
I tried using XL2BB but I am not able to (maybe it's a mac issue). Can I mail you or is there some workaround possible?
 
Upvote 0
Made an account just to say that this is absolutely fantastic. Thanks for all your work and continued support Alan.
 
Upvote 0
This is an amazing function, I've been using it to good success.

I have a question, though - what I need is the ability to do a fuzzy match with a condition.

I have a sheet, "Beers," that has beer names, a brewery ID, and a key for that beer:
1637286853071.png


I have another sheet with Brewery IDs and then some unrefined "Beer Names" that need to be mapped to a key in the beer sheet:
1637286967803.png


Beer names might be repeated many times across breweries, though, so I want to do the fuzzy lookup based on the BreweryID. What I tried is this:
Excel Formula:
=fuzzyvlookup(H9,FILTER(Beers!A2:E2437,Beers!B2:B2437=E9,""),5)

The FILTER() formula is correct, if I drop that into its own cell I get the array back that I expect, but I get the above #VALUE! when I try to use it.

How can I use the fuzzy vlookup under an additional condition?

Thanks!
 
Upvote 0
This is an amazing function, I've been using it to good success.

I have a question, though - what I need is the ability to do a fuzzy match with a condition.

I have a sheet, "Beers," that has beer names, a brewery ID, and a key for that beer:
View attachment 51617

I have another sheet with Brewery IDs and then some unrefined "Beer Names" that need to be mapped to a key in the beer sheet:
View attachment 51618

Beer names might be repeated many times across breweries, though, so I want to do the fuzzy lookup based on the BreweryID. What I tried is this:
Excel Formula:
=fuzzyvlookup(H9,FILTER(Beers!A2:E2437,Beers!B2:B2437=E9,""),5)

The FILTER() formula is correct, if I drop that into its own cell I get the array back that I expect, but I get the above #VALUE! when I try to use it.

How can I use the fuzzy vlookup under an additional condition?

Thanks!
Hi duckuser,
I'm constantly amazed that this piece of code is still useful after over 15 years!
Instead of the Filter function, try the parameters "GroupColOffset" and "GroupValue", as described in the comments in the code, the extract of which is here:
'** The following parameters allow matching by group, and only those values
'** which are in the group specified will be considered for matching.
'** GroupColOffset: This parameter specifies the offset column which contains the group values.
'** To trigger group matching, this must be a non-zero integer
'** GroupValue : This parameter specifies the Group to be considered for matching

Hope this helps

Alan
 
Upvote 0
where is the last release? (which post?)
would be more practical to share the file vs htm shared lol
 
Upvote 0

Forum statistics

Threads
1,224,835
Messages
6,181,245
Members
453,026
Latest member
cknader

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