
|
|
Sunday, February 03, 2002
Ed Acosta sent this note and a nice little bit of code. It is not a UDF, but if you need to perform a fuzzy match on two columns of numbers it will work well. I guess this is kind of late for the contest, but my code lines are less then the ones you posted and it works from what I tested. I basically determined that onces a match is made on the first string from the second string the next comparison starts from that point of the first string.
Wednesday, November 07, 2001
Damon Ostrander followed up with this code. It is nice and compact. Excellent entry from Damon. I'll queue him up for one of the MrExcel T-Shirts. First his comments, then the code: I took a different approach to the problem, writing a function using only built-in VBA resources. The function =Fuzzy("I B M","The IBM Corporation") to return the percentage match. I limited the first string to 24 characters max since the algorithm used is not the fastest--it does an exhaustive compare against every ordered combination of characters in the first string. I believe it could be made much more efficient via the use of Grey Code rather than straight binary so that each time a match is found all lesser matches would automatically be eliminated. This method yields the correct percentages for each of the examples given in the challenge including the IBM case above, which yields 60%.
Wednesday, October 31, 2001
Damon Ostrander checked in with this note: The problem definition is not entirely clear. For example, in the comparison of the two strings: "Ask MrExcel.com" there are supposed to be 11 characters that match. But what about the s in Ask matching with the s in Consulting? And if this is not a legitimate match, then what about matching the two strings: "Ask MrExcel.com" Would the two "Ask" strings not count as matching? Great questions. As I posted on October 17th, the characters must be in order to match. This would preclude the "s" in Ask to match the "s" in Consulting. If the letters could match in any order, then these two strings would be a 100% match: I like Damon's second question, which makes me want to change the original question. It would be tempting to include a "significant" number of sequential letters matching as in: Sunday, October 28, 2001
Andrew from Australia wrote with comments. Juan Pablo's code looks OK. The solution to handle the IBM pair is to swap str1 & str2 and re-run the i1 loop. Thanks to Andrew for his contribution. A MrExcel 2002 Olympic Calendar is on its way to Australia for his suggestion shown below.
Thursday, October 18, 2001
After Qroozn got us off to a stellar start ;-), Juan Pablo sent in the first serious stab at a solution. The thing works for every case except "I B M" and "IBM Corporation". Take a look at it, build on it.
Juan Pablo definitely has an official MrExcel.com 2002 Salt Lake City Official Olympic Calendar coming his way. Thanks for the entry. Wednesday, October 17, 2001
Back in 1999, I used to publish a monthly challenge. It would be an insane problem and I would offer a MrExcel.com Coffee Mug to whoever came up with the best answer. Well, I recently came across an insane problem. Web technology has come along. If you are a frequent reader of the message board, you can see how collaboration helps come to the optimal solution for a problem. Someone will ask a question, someone else will comment, someone else will build on that comment, etc. Now, with the Weblog technology, we can, in theory all collaborate right here on the Weblog. So - as a great big experiment, I am proud to annouce the return of the Challenge. I'll explain the problem below. Post your replies, thoughts, etc. below that. This is a tough challenge, so I will upgrade the prize offerings. Everyone who contributes and makes a significant contribution towards moving this challenge along to a solution will win an official MrExcel.com Olympic Winter Games Salt Lake 2002 Calendar. The calendar is packed with Winter Olympic history, schedules, and cool stickers for the kids. Whoever makes the most significant contribution to the answer with receive one of the super-deluxe embroidered MrExcel.com long sleeve denim shirts. Here is the problem: I would like to build in VBA a routine that will calculate a "fuzzy match" between two text strings. This routine will allow us to say that one string is a 75% match to the other string. Here are some examples: "Ask MrExcel.com" "I B M" "A. Schulman" Note that the characters have to be in order. "Elvis" It is really easy for our brains to look at those two strings and to pick out the patterns. I've challenged a few friends to try and do this in VBA, and we have concluded: "its hard!". There you have it. We'll let the challenge run until we all come up with some sort of a solution or mutually agree that it can not be done. If you have comments, ideas, etc. you can either e-mail the to Challenge@MrExcel.com or click the little comment hyperlink below and post it interactively. If you send e-mail, I will periodically summarize and post here. Best of luck.
|
MrExcel.com provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures on this web site are provided "as is" and we do not guarantee that they can be used in all situations.
Return to the Mr Excel Home Page.
Thanks for visiting Mr Excel.com! Proudly serving the web since November 21, 1998.
All contents copyright 2001 by MrExcel.com.
Send questions to ask@MrExcel.com
Excel is a registered trademark of the Microsoft Corporation.