![]() |
#15
|
|||
|
|||
![]()
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 |
Tags |
list, randomizer, word 2010 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dropdown List in Microsoft Word 2010 | bfarquhar | Word | 2 | 04-02-2014 07:48 PM |
![]() |
norwood | Word VBA | 2 | 02-03-2014 06:49 PM |
Word 2010: how to save numbered list indent to 0? | michaelbr | Word | 5 | 12-12-2013 09:35 PM |
![]() |
shaukat74 | Word VBA | 1 | 01-29-2013 09:34 PM |
![]() |
jomarie | Office | 1 | 02-19-2012 07:45 PM |