ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Flipping a name (https://www.excelbanter.com/excel-programming/329651-re-flipping-name.html)

Trent Argante

Flipping a name
 
Sub Selection_Loop()
Dim rngSelection As Range
Set rngSelection = Selection
Dim varCell As Variant

Dim intSpacePosition As Integer
Dim strFirstName As String
Dim strLastName As String

For Each varCell In rngSelection.Cells

With varCell
intSpacePosition = InStr(.Value, " ")
strFirstName = Left(.Value, intSpacePosition - 1)
strLastName = Mid(.Value, intSpacePosition + 1)

.Value = strLastName & ", " & strFirstName
End With

Next
End Sub
HTH
--
Trent Argante
[DC.J(<#)]


"Duncan_J" wrote:

If I got column of names
John Doe

And what to change it to
Doe, John

Is thier a way of doing this?

DJ



All times are GMT +1. The time now is 05:07 PM.

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