ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change order of data in a cell (https://www.excelbanter.com/excel-programming/422055-re-change-order-data-cell.html)

Seyed

Change order of data in a cell
 

I suggest using the Split function:

Sub SplitThenReverse()
Dim txt, a, i, range

'''''This can be the selected Cell''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''
txt = "First,Middle,Last"

'''''''''''''You may change the delimeter to anything you like'''''''''''''
''''''''''''and Note that it will return an Array of string
''''''''''''''''''''''''
a = Split(txt, ",")
Length = UBound(a)
For i = 0 To Length
MsgBox (a(Length - i))
Next i


End Sub

Ofcourse you may replace the MsgBox() with appropriate assignment to your
desired cell.

"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 03:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com