Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change order of data in a cell | Excel Programming | |||
Change order of data in a cell | Excel Programming | |||
How to change the series order in a LEGEND ONLY...not data | Charts and Charting in Excel | |||
Change order of data in a cell | Excel Discussion (Misc queries) | |||
How do I change the order of the series in the Source Data? | Charts and Charting in Excel |