Sub ParseName(strInName As String, strTemp() As String)
Dim intSpacePos As Integer
Dim I As Integer
ReDim LastWord(1 To 3) As String
ReDim strTemp(0) As String
ReDim ExpandedName(1 To 3) As String
Dim CheckWord As String
Dim FoundCount As Integer
intSpacePos = InStr(strInName, " ")
Do Until intSpacePos = 0
' add empty element to end of array
ReDim Preserve strTemp(UBound(strTemp) + 1)
' fill element with found word+space
strTemp(UBound(strTemp)) = Trim$(Left$(strInName, intSpacePos - 1)) & " "
' remove found word from input string
strInName = LTrim$(Right$(strInName, Len(strInName) - intSpacePos))
' look for next space
intSpacePos = InStr(strInName, " ")
' if company name is null filled this gets last word
If intSpacePos = 0 Then
' this stops extra word when company name is not null filled
If Len(strInName) > 0 Then
ReDim Preserve strTemp(UBound(strTemp) + 1)
strTemp(UBound(strTemp)) = Trim$(Left$(strInName, Len(strInName))) & " "
strInName = LTrim$(Right$(strInName, Len(strInName) - intSpacePos))
End If
End If
Loop
' look at each word in array and expand if in list
For I = 1 To (UBound(strTemp))
If strTemp(I) = "" Then
Exit For
End If
Select Case strTemp(I)
Case "ACC "
strTemp(I) = "ACCIDENT "
Case "AGRIC "
strTemp(I) = "AGRICULTURAL "
Case "AMER ", "AM "
strTemp(I) = "AMERICAN "
Case "AND "
strTemp(I) = "& "
Case "ASSN ", "ASN"
strTemp(I) = "ASSOCIATION "
Case "AUTOMOBILE "
strTemp(I) = "AUTO "
Case "BUR "
strTemp(I) = "BUREAU "
Case "CALIF "
strTemp(I) = "CALIFORNIA "
Case "CAS "
strTemp(I) = "CASUALTY "
Case "CO ", "CO. "
strTemp(I) = "COMPANY "
Case "COS "
strTemp(I) = "COMPANIES "
Case "COMP "
strTemp(I) = "COMPENSATION "
Case "CONSTIT "
strTemp(I) = "CONSTITUTION "
Case "CONTRIB "
strTemp(I) = "CONTRIBUTIONSHIP "
Case "CORP ", "CORP. "
strTemp(I) = "CORPORATION "
Case "FID "
strTemp(I) = "FIDELITY "
Case "FIN "
strTemp(I) = "FINANCIAL "
Case "GEN ", "GENL "
strTemp(I) = "GENERAL "
Case "GR ", "GRP "
strTemp(I) = "GROUP "
Case "GUAR "
strTemp(I) = "GUARANTY "
Case "PROP "
strTemp(I) = "PROPERTY "
Case "INC "
strTemp(I) = "INCORPORATED "
Case "INDEM "
strTemp(I) = "INDEMNITY "
Case "INS ", "INS. ", "IN "
strTemp(I) = "INSURANCE "
Case "INTL ", "INTERNATL "
strTemp(I) = "INTERNATIONAL "
Case "LIAB "
strTemp(I) = "LIABILITY "
Case "L&A "
strTemp(I) = "LIFE & ACCIDENT "
Case "MAR "
strTemp(I) = "MARINE "
Case "MICH "
strTemp(I) = "MICHIGAN "
Case "MUT "
strTemp(I) = "MUTUAL "
Case "NAT ", "NATL "
strTemp(I) = "NATIONAL "
Case "PAC "
strTemp(I) = "PACIFIC "
Case "PENN "
strTemp(I) = "PENNSYLVANIA "
Case "PROP "
strTemp(I) = "PROPERTY "
Case "PHILA "
strTemp(I) = "PHILADELPHIA "
Case "P&C "
strTemp(I) = "PROPERTY & CASUALTY "
Case "RE ", "REINS ", "REIN "
strTemp(I) = "REINSURANCE "
Case "ST. ", "SAINT"
strTemp(I) = "ST "
Case "TRANSAM "
strTemp(I) = "TRANSAMERICA "
Case "UNIV "
strTemp(I) = "UNIVERSAL "
Case "US "
strTemp(I) = "U.S. "
End Select
Next I
'''''build company name
' handle case where input string was empty
If UBound(strTemp) <> 0 Then
strInName = strTemp(1)
End If
' put words back into a string
For I = 2 To (UBound(strTemp))
strInName = strInName & strTemp(I)
Next I
'''''save max index
I = (UBound(strTemp))
'Check to see if last word in any name is "Company",
'If it is, then all names must end with "Company"
CheckWord = "Company "
FoundCount = 0
For I = 1 To 3
GoSub CheckLastWord
Next I
If FoundCount = 1 Or FoundCount = 2 Then
For I = 1 To 3
GoSub AppendLastWord
Next I
End If
Exit Sub
CheckLastWord:
If LastWord(I) = CheckWord Then
FoundCount = FoundCount + 1
End If
Return
AppendLastWord:
If LastWord(I) <> CheckWord Then
ExpandedName(I) = Trim(ExpandedName(I)) & " " & CheckWord
End If
Return
End Sub