Randomize a list

K

Kevin G

I saw back on 7-12-03 that someone asked how to randomize
a range of string values. The answer that was given
referenced a book that I don't have. Could anyone help me
with a rangerandomizer function? I'm at work and can't
get to a library or bookstore right now.

Thanks,

Kevin
 
R

Ron de Bruin

J.E posted this in the same thread
Did you try that one

Public Sub RandomizeRange()
Dim temp As Variant
Dim arr As Variant
Dim rng As Range
Dim i As Integer, i1 As Integer
Dim j As Integer, j1 As Integer

Set rng = Range("A1:E5")
arr = rng.Value
For i = UBound(arr, 1) To 1& Step -1&
For j = UBound(arr, 2) To 1& Step -1&
i1 = Int(Rnd() * i) + 1&
j1 = Int(Rnd() * j) + 1&
temp = arr(i, j)
arr(i, j) = arr(i1, j1)
arr(i1, j1) = temp
Next j
Next i
rng.Value = arr
End Sub
 
K

Kevin G

Ron,

I didn't see it because I did a search on random and it
only showed the first post and the book reference post.
Thanks for the quick response!!

Kevin
 

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