Change order of data in a cell
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 |
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 |
All times are GMT +1. The time now is 07:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com