Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Randomly Re-arrange Entries in an array.

Hi,

I have a 203x203 array of non-negative numbers which I want to re-arrange at
random in another sheet. I've tried creating and using an array of random
numbers in another sheet to reorder the data but it isn't quite working out.

Does anybody know of a formula I can use to accomplish this?

Many thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Randomly Re-arrange Entries in an array.

1. We copy the table to a single column on tab sh2
2. We shuffle the single column of tab sh2
3. We copy the single column on sh2 to a table on sh3

Sub shuffle()
Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
Dim i As Integer, j As Integer, k As Long
Set sh1 = Sheets("sh1")
Set sh2 = Sheets("sh2")
Set sh3 = Sheets("sh3")
sh1.Activate
Application.ScreenUpdating = False
Application.Calculation = xlManual

k = 1
For i = 1 To 203
For j = 1 To 203
sh2.Cells(k, 1).Value = Cells(i, j).Value
k = k + 1
Next
Next

sh2.Activate
Range("B1:B41209").Formula = "=rand()"
Columns("A:B").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo

k = 1
For i = 1 To 203
For j = 1 To 203
sh3.Cells(i, j).Value = Cells(k, 1).Value
k = k + 1
Next
Next
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub

--
Gary''s Student - gsnu200832


"james_tasker" wrote:

Hi,

I have a 203x203 array of non-negative numbers which I want to re-arrange at
random in another sheet. I've tried creating and using an array of random
numbers in another sheet to reorder the data but it isn't quite working out.

Does anybody know of a formula I can use to accomplish this?

Many thanks

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
randomly select a cell from an array TLC Excel Discussion (Misc queries) 7 April 22nd 23 07:43 PM
Can I randomly select values from an array with removal? bvc Excel Discussion (Misc queries) 2 February 17th 08 10:49 PM
Array formula for unique entries Martina Excel Worksheet Functions 4 August 11th 07 02:00 AM
Can Excel randomly pick one winner out of 100 contest entries? Bernard Excel Discussion (Misc queries) 4 March 30th 07 04:28 PM
How do I arrange entries in a column alphabetically ferrymaster77 Excel Discussion (Misc queries) 1 January 21st 05 11:58 AM


All times are GMT +1. The time now is 04:12 PM.

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

About Us

"It's about Microsoft Excel"