LastName, FirstName format

T

Todd Huttenstine

Hey guys,

In range A5:A100 I have names. The names are in format of
LastName, FirstName (example: Huttenstine, Todd). What is
a code I can run that will go through this range and for
every value that it finds a "," in it, it reverse the
order and take out the "," so it shows FirstName LastName.

Example:

Huttenstine, Todd turns into Todd Huttenstine.

Thanx
Todd
 
T

Tom Ogilvy

Sub Tester12()
Dim sStr As String
Dim cell As Range
For Each cell In Range("A5:A100")
If Not IsEmpty(cell) Then
If InStr(cell, ",") Then
sStr = Right(cell, Len(cell) _
- InStr(cell, ","))
cell.Value = Trim(sStr) & " " & _
Trim(Left(cell, _
InStr(cell, ",") - 1))
End If
Else
Exit For
End If
Next

End Sub
 
T

Todd Huttenstine

Thank you.

-----Original Message-----
Sub Tester12()
Dim sStr As String
Dim cell As Range
For Each cell In Range("A5:A100")
If Not IsEmpty(cell) Then
If InStr(cell, ",") Then
sStr = Right(cell, Len(cell) _
- InStr(cell, ","))
cell.Value = Trim(sStr) & " " & _
Trim(Left(cell, _
InStr(cell, ",") - 1))
End If
Else
Exit For
End If
Next

End Sub

--
Regards,
Tom Ogilvy





.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top