Forum Discussion
M.Emre CANAL
Apr 24, 2017Copper Contributor
To inverse the words
I want write inversely the words in the same cell. For example; ( Washington-Paris-Ankara-Madrid) inversely>>(Madrid-Ankara-Paris-Washington) Thank you
Chip Pearson
Apr 28, 2017Copper Contributor
body { font-family:arial; font-size:12pt; color:navy } body .code { font:mono-spaced; font-size:12pt; color:navy; } body .comment { font-family:mono-spaced; font-size:12pt; color:green; }
Here's some very simple code to do it.
Sub ReverseList()
Dim SS() As String
Dim T As String
Dim N As Long
On Error GoTo ErrH:
SS = Split(ActiveCell, "-")
Application.EnableEvents = False
For N = UBound(SS) To LBound(SS) Step -1
T = T + SS(N) + "-"
Next N
T = Left(T, Len(T) - 1)
ActiveCell.Value = T
ErrH:
Application.EnableEvents = True
Debug.Print T
End Sub