I have several lists of more than 1000 names entered as a single column in Excel 2010
I need to split each string into fields such as FName, LName, MName, Title, Suffix
sample data:
[TABLE="width: 173"]
<tbody>[TR]
[TD]Dr. Bill Lovejoy[/TD]
[/TR]
[TR]
[TD]Dr. Raymond Lutz, Jr.[/TD]
[/TR]
[TR]
[TD]Dr. Nancy Lutz[/TD]
[/TR]
[TR]
[TD]William Macey[/TD]
[/TR]
[TR]
[TD]Paul and Denise Maestas[/TD]
[/TR]
[TR]
[TD](and many other variants)
[/TD]
[/TR]
</tbody>[/TABLE]
I've written a VB program that handles most of the cases and
identifies FName, LName, MName, Title, Suffix reading one string at a time. see commented out strTest=
Now I need to modify this to read the string strText from column A and write the five fields above in col B-F
Notice that StrTest is redefined in the code after I've handled the title and suffix in order to make a simpler string for the next step.
I don't known how to set the data types and loop through the spreadsheet to read the data. I attempted to set strTest as variant, but it stops when I redefine it. Setting it as range as I've tried here doesn't work.
Thanks,
ABQDave
Private Sub cleanNames()
Dim strTest As Range
Dim Fname As String
Dim Lname As String
Dim Mname As String
Dim WifeName As String
Dim Title As String
Dim Suffix As String
Dim strArray() As String
Dim intCount As Integer
Dim intSpaces As Integer
Dim intLen As Integer
Dim intComma As Integer
'strTest = "J. Douglas Mistler, USA (Ret.)"
For Each strTest In Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
strTest = Trim(strTest)
intLen = Len(strTest)
intComma = InStr(strTest, ",")
'handle suffix--anything after a comma
Suffix = Right(strTest, (intLen - intComma))
strTest = Left(strTest, intComma - 1)
intLen = Len(strTest)
Debug.Print intComma, Suffix, strTest1
'deal with titles
etc
I need to split each string into fields such as FName, LName, MName, Title, Suffix
sample data:
[TABLE="width: 173"]
<tbody>[TR]
[TD]Dr. Bill Lovejoy[/TD]
[/TR]
[TR]
[TD]Dr. Raymond Lutz, Jr.[/TD]
[/TR]
[TR]
[TD]Dr. Nancy Lutz[/TD]
[/TR]
[TR]
[TD]William Macey[/TD]
[/TR]
[TR]
[TD]Paul and Denise Maestas[/TD]
[/TR]
[TR]
[TD](and many other variants)
[/TD]
[/TR]
</tbody>[/TABLE]
I've written a VB program that handles most of the cases and
identifies FName, LName, MName, Title, Suffix reading one string at a time. see commented out strTest=
Now I need to modify this to read the string strText from column A and write the five fields above in col B-F
Notice that StrTest is redefined in the code after I've handled the title and suffix in order to make a simpler string for the next step.
I don't known how to set the data types and loop through the spreadsheet to read the data. I attempted to set strTest as variant, but it stops when I redefine it. Setting it as range as I've tried here doesn't work.
Thanks,
ABQDave
Private Sub cleanNames()
Dim strTest As Range
Dim Fname As String
Dim Lname As String
Dim Mname As String
Dim WifeName As String
Dim Title As String
Dim Suffix As String
Dim strArray() As String
Dim intCount As Integer
Dim intSpaces As Integer
Dim intLen As Integer
Dim intComma As Integer
'strTest = "J. Douglas Mistler, USA (Ret.)"
For Each strTest In Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
strTest = Trim(strTest)
intLen = Len(strTest)
intComma = InStr(strTest, ",")
'handle suffix--anything after a comma
Suffix = Right(strTest, (intLen - intComma))
strTest = Left(strTest, intComma - 1)
intLen = Len(strTest)
Debug.Print intComma, Suffix, strTest1
'deal with titles
etc