Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Randomize a list

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Randomize a list

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



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Kevin G" wrote in message ...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Randomize a list

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
-----Original Message-----
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



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Kevin G" wrote in message

...
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



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Randomize a list

You probably would have had better luck if you searched this group for the
word shuffle:

http://groups.google.com/groups?as_q...ng&lr= &hl=en

URL should be all one line. Reconstitute it and paste into your browser.

Regards,
Tom Ogilvy


"Kevin G" wrote in message
...
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
-----Original Message-----
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



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Kevin G" wrote in message

...
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



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Randomize from a list PEGWINN Excel Discussion (Misc queries) 12 August 4th 09 11:59 AM
randomize a list LelandKramer Excel Discussion (Misc queries) 1 July 13th 09 09:29 PM
How do I randomize a list of 20 people? Ken P Excel Discussion (Misc queries) 2 August 8th 06 10:36 PM
How do I randomize a list without repeats K9CE Excel Discussion (Misc queries) 2 October 13th 05 07:01 PM
Randomize a list of names Steve[_27_] Excel Programming 4 July 22nd 03 07:26 AM


All times are GMT +1. The time now is 07:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"