Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change order of data in a cell Seyed Excel Programming 0 January 6th 09 11:25 PM
Change order of data in a cell Ron Rosenfeld Excel Programming 0 January 6th 09 09:40 PM
How to change the series order in a LEGEND ONLY...not data Steve P[_2_] Charts and Charting in Excel 2 December 3rd 08 08:44 AM
Change order of data in a cell Mary-Anne Excel Discussion (Misc queries) 3 October 30th 08 09:51 AM
How do I change the order of the series in the Source Data? Earl Charts and Charting in Excel 2 February 2nd 05 03:09 PM


All times are GMT +1. The time now is 08:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"