Random Sorting

G

Greg Maxey

Found this in Google. Try:


Sub RandomWords()
Dim myArray() As String, myTemp As String
Dim Index As Long, OtherIndex As Long

If Selection.Type = wdSelectionIP Then
MsgBox "Please select some words"
Exit Sub
End If

myArray = Split(Selection.Text)
Randomize
For Index = 0 To UBound(myArray)
OtherIndex = Rnd * UBound(myArray)
myTemp = myArray(Index)
myArray(Index) = myArray(OtherIndex)
myArray(OtherIndex) = myTemp
Next Index

Selection.Text = Join(myArray)
End Sub
 
J

Jezebel

Another method, that doesn't involve code and let's you experiment: copy the
text and paste into an Excel spreadsheet. Insert a column. Select an
arbitrary substring from each item of text eg =Mid(A1,6,4) to take 4
characters starting with the sixth. Sort on that column. Copy and paste back
into Word.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top