#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Random

Hello,

I have an array as follows:

Dim data(1 To 6, 1 To 6) As String

Then I give values to my array:

data(1,1) = "Value 1"
data(1,2) = "Value 2"
....
data(6,6) = "Value 36"

How can I, after all values had been assigned to data, randomly
redistribute them?

Thanks,
Miguel
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Random

Pass your array to the Sub below, e.g. Shuffle myArray

Hth,
Merjet

Sub Shuffle(strX() As String)
Dim iCt As Integer
Sheets.Add after:=Sheets(Sheets.Count)
For iCt = 1 To 36
Cells(iCt, 1) = strX(1 + Int((iCt - 1) / 6), 1 + (iCt - 1) Mod
6)
Cells(iCt, 2) = Rnd()
Next iCt
Range("A1:B36").Sort Key1:=Range("B1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
For iCt = 1 To 36
strX(1 + Int((iCt - 1) / 6), 1 + (iCt - 1) Mod 6) = Cells(iCt,
1)
Next iCt
Application.DisplayAlerts = False
Sheets(Sheets.Count).Delete
Application.DisplayAlerts = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 806
Default Random

Hello Miguel,

Sub t1()
Dim data(1 To 6, 1 To 6) As String
Dim vrndarray
Dim i As Long, j As Long
vrndarray = VBUniqRandInt(36, 36)
For i = 1 To 6
For j = 1 To 6
data(i, j) = "Value " & vrndarray(i * 6 + j - 6)
Next j
Next i
End Sub

You can find my UDF vbuniqrandint he
http://www.sulprobil.com/html/uniqrandint.html

Regards,
Bernd
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
Random phantom breakpoints and random bogus compile errors Greg Lovern Excel Programming 5 June 2nd 10 03:52 PM
Sorting random Data created from a random formula Six Sigma Blackbelt Excel Discussion (Misc queries) 1 September 11th 08 11:03 PM
Non-random numbers generated by excel's data analysis random gener Allie Excel Worksheet Functions 10 September 17th 05 06:19 AM
Non-random numbers generated by excel's data analysis random gener Harlan Grove Excel Discussion (Misc queries) 2 September 13th 05 04:06 PM
How do I find random number in list of random alpha? (Position is. jlahealth-partners Excel Discussion (Misc queries) 0 February 8th 05 05:31 PM


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

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"