ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to move first name to last position in cell (https://www.excelbanter.com/excel-programming/310203-macro-move-first-name-last-position-cell.html)

Annette[_4_]

Macro to move first name to last position in cell
 
I need a macro that will transpose the first name with the last name in each
of the cells of numerous spreadsheets in column A ... some of the users had
put in the names first last while other formatted their as last, first ...

We want them to appear as last, first on all. Is there a method to do so?

Thanks!



JE McGimpsey

Macro to move first name to last position in cell
 
one way:

Public Sub TransposeNames()
Dim rCell As Range
Dim sTemp As String
For Each rCell In Selection
sTemp = rCell.Text
If InStr(sTemp, ",") = 0 Then
sTemp = Application.Trim( _
Mid(sTemp, InStr(sTemp, " ")) & ", " & _
Left(sTemp, InStr(sTemp, " ") - 1))
rCell.Value = sTemp
End If
Next rCell
End Sub




In article ,
"Annette" wrote:

I need a macro that will transpose the first name with the last name in each
of the cells of numerous spreadsheets in column A ... some of the users had
put in the names first last while other formatted their as last, first ...

We want them to appear as last, first on all. Is there a method to do so?

Thanks!


Annette[_4_]

Macro to move first name to last position in cell
 
Thanks!

"JE McGimpsey" wrote in message
...
one way:

Public Sub TransposeNames()
Dim rCell As Range
Dim sTemp As String
For Each rCell In Selection
sTemp = rCell.Text
If InStr(sTemp, ",") = 0 Then
sTemp = Application.Trim( _
Mid(sTemp, InStr(sTemp, " ")) & ", " & _
Left(sTemp, InStr(sTemp, " ") - 1))
rCell.Value = sTemp
End If
Next rCell
End Sub




In article ,
"Annette" wrote:

I need a macro that will transpose the first name with the last name in

each
of the cells of numerous spreadsheets in column A ... some of the users

had
put in the names first last while other formatted their as last, first

....

We want them to appear as last, first on all. Is there a method to do

so?

Thanks!





All times are GMT +1. The time now is 02:25 PM.

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