View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Change order of data in a cell


hi,

I forgot a tip given me by Rick Rothstein you don't need LEN with MID if you
want to pick up all of the remainder of the string

Sub sonic()
For Each c In Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
lastnm = Trim(Left(c, InStr(c, " ")))
firstname = Mid(c, InStr(c, " "))
c.Value = LTrim(firstname & " " & lastnm)
Next
End Sub

Mike

"Mike H" wrote:

Hi,

Assumes your names in column A. Right click your sheet tab, view code and
paste this in and run it

Sub sonic()
For Each c In Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
lastnm = Trim(Left(c, InStr(c, " ")))
firstname = Mid(c, InStr(c, " "), Len(c))
c.Value = LTrim(firstname & " " & lastnm)
Next
End Sub

Mike

"David" wrote:

Is it possible to write a macro that will change cells that have "Last Name,
First Name, Middle Initial" to "First Name, Middle Initial, Last Name" ?
Thank you for your help.
David