Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2014, 06:52 PM
gmaxey gmaxey is offline List Randomizer Macro for Word 2010 Windows 7 32bit List Randomizer Macro for Word 2010 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
Reply

Tags
list, randomizer, word 2010



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown List in Microsoft Word 2010 bfarquhar Word 2 04-02-2014 07:48 PM
List Randomizer Macro for Word 2010 Word 2003 Macro problem running in Word 2010 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
List Randomizer Macro for Word 2010 MAcro to List all the Font & its size in a word document shaukat74 Word VBA 1 01-29-2013 09:34 PM
List Randomizer Macro for Word 2010 Word 2010 Macro jomarie Office 1 02-19-2012 07:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft