ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   LastName, FirstName format (https://www.excelbanter.com/excel-programming/285421-lastname-firstname-format.html)

Todd Huttenstine[_2_]

LastName, FirstName format
 
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

Tom Ogilvy

LastName, FirstName format
 
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


Todd Huttenstine wrote in message
...
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




Todd Huttenstine[_2_]

LastName, FirstName format
 
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


Todd Huttenstine

wrote in message
...
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



.



All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com