Solved

Excel - Formula or VBA to allow matching of partial names, abbreviated names and nicknames

Posted on 2014-01-21
3
1,014 Views
Last Modified: 2014-01-21
I work in an environment were information is collected from students and manually entered into spreadsheets by a large number of different people (sometimes the students themselves).  The names of the students on the supplied spreadsheets can have 4 or 5 variations due to the use of nicknames, abbreviations, spelling errors and the like.  I would like to create a system where the supplied name can be matched to the correct and formal name of the student.  I have created a table with 5 name columns for each student.  In this table the formal name of the athlete is entered in column 2 (column 1 is an ID number) and any known abbreviations, nicknames or abbreviations are entered in columns C,D,E and F.  If the supplied name matches any of the known alternate names then a successful match can be made and the correct Formal Name and ID number applied to the data record.  I have written a match function to accomplish this but i am interested in any alternative suggestions to make this task work smoothly and cope with any new alternate names that may be entered i.e. add them to the list of alternate names.  A VBA solution is OK as the master document is already a xlsm file.  Sample file is attached.
Names-Database.xlsx
0
Comment
Question by:JohnNZExcel
  • 2
3 Comments
 
LVL 81

Assisted Solution

by:byundt
byundt earned 500 total points
ID: 39799137
The following brute force formula works for data entry into cell H1:
=INDEX(RngAthleteNames,IFERROR(MATCH(H1,RngAthleteNames,0),IFERROR(MATCH(H1,RngAltNames1,0),IFERROR(MATCH(H1,RngAltNames2,0),IFERROR(MATCH(H1,RngAltNames3,0),IFERROR(MATCH(H1,RngAltNames4,0),""))))))
0
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 39799153
I created a named range AllNames that is the union of RngAthleteNames, RngAltNames1, RngAltNames2, RngAltNames3 and RngAltNames4. I then wrote a user-defined function (in a regular modules sheet) called FormalName. You can use it with a worksheet formula like:
=FormalName(H1, AllNames)              where H1 is the data entered by the user
Function FormalName(InputName As String, rngNames As Range)
Dim v As Variant
Dim i As Long, nCols As Long
FormalName = "Not found"
nCols = rngNames.Columns.Count
For i = 1 To nCols
    v = Application.Match(InputName, rngNames.Columns(i), 0)
    If Not IsError(v) Then
        FormalName = rngNames(CLng(v), 1).Value
        Exit Function
    End If
Next
End Function

Open in new window

0
 

Author Closing Comment

by:JohnNZExcel
ID: 39799255
Greatly appreciate you providing both an improved formulaic solution as well as a neat looking UDF.  I will work with both and see how everything goes.  Thank you, thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now