Reversing word order - is it possible?

  • Thread starter Thread starter Bert Coules
  • Start date Start date
B

Bert Coules

Is there a way (apart from doing it manually, of course) of reversing the
word order of a block of text? So that, for example, "This sentence is
normal" becomes "normal is sentence this"?

Easy enough to do for four words, but (for reasons far too unbelievable to
go into) I have to reverse several chunks of text running to a hundred words
or so each.

Many thanks,

Bert
www.bertcoules.co.uk
 
Bert,

There are probably better ways, but this seems to do the basic job.

Select the sentence (minus the final punctuation) and run this macro:

Sub RevOrder()
Dim i As Long
Dim myArray() As String
Dim myStr As String
myArray = Split(Selection.Text, " ")
For i = UBound(myArray) To 0 Step -1
myStr = myStr + " " & myArray(i)
Next i
myStr = Trim(myStr)
Selection.Delete
Selection.InsertAfter myStr
End Sub
 
Back
Top