View Single Post
 
Old 04-20-2014, 06:52 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,598
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Dennis,

Paul and Gerry I think are Microsoft MVPs in good standing. That means (or used to at least) that they have a world wide reputation for being helpful. I on the other hand quit the MVP program before being dismissed for my more acerbic style.

Despite your earlier assertions, you were not dissed here or elsewhere. Your subsequent apologies are both warranted and I think well received.

As best I can tell, Paul's solution is based on a " " (space) separated list. Here is a slight variation based on a paragraph separated list:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim lngIndex As Long
Dim arrWords() As String
Dim arrRandom
  arrWords = Split(Left(Selection.Range.Text, Len(Selection.Range.Text) - 1), vbCr)
  arrRandom = RandomizeArray(arrWords)
  Selection.Delete
  For lngIndex = 0 To UBound(arrRandom)
    Selection.Range.Text = Selection.Range.Text & arrRandom(lngIndex) & vbCr
  Next lngIndex
End Sub
  
 Function RandomizeArray(arrInput() As String) As Variant
Dim lngIndex As Long
Dim varTemp As Variant
Dim lngRandom As Long
Dim varRandomized As Variant
   
  Randomize
  ReDim varRandomized(LBound(arrInput) To UBound(arrInput))
  For lngIndex = LBound(arrInput) To UBound(arrInput)
    varRandomized(lngIndex) = arrInput(lngIndex)
  Next lngIndex
  For lngIndex = LBound(arrInput) To UBound(arrInput)
    lngRandom = CLng(((UBound(varRandomized) - lngIndex) * Rnd) + lngIndex)
    varTemp = varRandomized(lngIndex)
    varRandomized(lngIndex) = varRandomized(lngRandom)
    varRandomized(lngRandom) = varTemp
  Next lngIndex
  RandomizeArray = varRandomized
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote