Random mix up

  • Thread starter Thread starter TimLucky1
  • Start date Start date
T

TimLucky1

Is there a way I can take a column of cells lets say C1 to C10 and use a macro
to mixup the cells in a random order? Without effecting the information in the
cells?


Thanks

Tim
 
Hi Tim!

Not a macro, but you could record this procedure and make
it a macro:

In D1 enter this formula: =RAND()
Copy down as needed or double click the fill handle.
Select the range, C1:D10 and do a sort on col D.

Biff
 
One way:

Public Sub MixUp()
Dim vArr As Variant
Dim vTemp As Variant
Dim rng As Range
Dim i As Long
Dim nRand As Long

Set rng = Range("C1:C10")
vArr = rng.Value
For i = UBound(vArr, 1) To 2 Step -1
nRand = Int(Rnd() * i) + 1
vTemp = vArr(nRand, 1)
vArr(nRand, 1) = vArr(i, 1)
vArr(i, 1) = vTemp
Next i
rng.Value = vArr
End Sub
 
Back
Top