Solved

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

Posted on 2014-01-21
3
1,052 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

791 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