Thread: Reversing Words
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Reversing Words

Assuming the two words are separated by a space:

Sub ReverseName()
Dim sStr As String
Dim cell As Range
For Each cell In Range("B5:B105")
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 B5:B105 I have a list of names. They
are formatted as Lastname/Firstname. I need a code that
will go through all the names in this range and reverse
the order of the names.

For example... Huttenstine Todd needs to turn into Todd
Huttenstine

Tom gave me a code that took the commas out, but this time
there are no commas to take out.

Thank you.


Todd