Sets the array dimension at 100. If you want to sort more than 100 lines you need to bump this up.

paracount = Selection.Paragraphs.Count

This counts the number of paragraphs that have been selected and stores it in the paracount variable.

For x = 1 To paracount
paragaphz(x) = Selection.Paragraphs(x)
Next x

Loads the paragaphz array with the highlighted items. Each item in the array is a paragraph. It would appear the Selection function stores the contents of each paragraph in an array.

For y = 1 To (paracount * Int((paracount * Rnd) + 1))

The For loop will run for a random number of times. It will run at least as many times as there are highlighted paragraphs and likely more. If there are 10 items, the loop will run 10 * a random number between 1 and 10. So for example 10*5= 50 times. This should be a tip off that my randomization process is going to be highly inelegant.

Now we pick two different random numbers. One gets loaded in the pararand1 variable and one gets loaded in the pararand2 variable. If the numbers are the same (eg pararand1 = 4 and pararand2 = 4) then the Loop While function does the loop again, making the macro pick two more and keeps looping until the random function coughs up two unique numbers. Again tip off #2 that my coding is ham fisted and relies on brute force.

parastore = paragaphz(pararand1)

The parastore variable stores the contents of the first randomly selected array member.

paragaphz(pararand1) = paragaphz(pararand2)

The first randomly selected array member gets the value held in the second randomly selected array member.

paragaphz(pararand2) = parastore

The second randomly selected array member gets the value previously held in the first randomly selected array member (which was preserved in the parastore temp variable)

What we've accomplished here is just picking two random array members and having them swap values.

Next y

And this is the part where a good programmer would truly beat me about the face and neck. We do it all over again. In essence we're shuffling the deck. Randomly picking 2 list members have having them swap places. If we do this enough bloody times, the resultant list will look random enough. I know there are more elegant ways of randomizing an array that requires a lot less iteration...

Not extremely efficient -- but you know what? Who cares! These days 2gHz processors are the norm. It's not like you're doing this a million times.

Thanks for your effort and I'm sure it will find a lot of use.

Long time ago I wrote this sci fi role playing aid in visualbasic. It generated star systems. It was pretty nifty and very useful and I'd get a lot of email from people saying how great it worked, but I also included the source code. I did admit in the code that I wasn't a programmer and my coding was bletcherous to the max ("This is what happens when you create a development environment that non programmers can program in!"). I would get programmers that would agree with that statement...