View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Last Name First pt2

Jim gave you VBA code:


Sub ChangeOrder()
Dim cell as Range
for each cell in Selection
cell.Value = FormatName(Cell.Text)
Next
end Sub



Public Function FormatName( _
ByVal InputName As String) As String
FormatName = Right(InputName, Len(InputName) - _
InStrRev(Trim(InputName), " ")) & _
", " & Trim(Left(InputName, InStrRev(InputName, " ")))
End Function

--
regards,
Tom Ogilvy


"snax500" wrote in message
ups.com...
Earlier, I posted the following question and thanks for the great
responses:


In Excel2000, I have the following data:


John P. Henry
Craig Nelson


I want to use a macro to make the last name first even if there is a
middle initial ( no space between comma and First name). I want it to
look like this:


Henry,John P.
Nelson,Craig


Any ideas?

Maybe, I wasn't clear but I do not want a formula or a function. I want
a macro to go through my original list and change the name from first
last to last,first. I already have list of names and just want to do a
conversion on the selected cells. I think I would be using InStr or
some other string functions in Visual Basic.

Thanks again.





Thanks