View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Jim Cone
 
Posts: n/a
Default How do I sort numbers in a table (ie. rows & columns)?

I had a private message requesting the random number VBA code...

'Fills first R rows by C columns with random numbers
'from 1 to (R * C) - without any duplicates.
'Jim Cone - August 20, 2004 - San Francisco, USA
'--------------------------------
Sub MixThemUp()
Dim i As Long
Dim j As Long
Dim N As Long
'Specify number of rows and columns.
Const R As Long = 30
Const C As Long = 10
Const lngFiller As Long = 9999
Dim ArrOne(1 To C)
Dim ArrTwo(1 To (R * C))

'30 loops for 30 rows
For N = 1 To R
j = 1
'10 loops for ten columns
Do While j < (C + 1)
Randomize (j * N)
'Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
i = Int(Rnd * (R * C) + 1)
If ArrTwo(i) < lngFiller Then
ArrOne(j) = i
ArrTwo(i) = lngFiller
j = j + 1
End If
Loop
'Fill each row with the array values
Range(Cells(N, 1), Cells(N, 10)).Value = ArrOne()
Next 'N
End Sub
'---------------------------------------------------------



"Jim Cone"
wrote in message

T,
My Excel add-in Special Sort can sort the data in a table - either across
the rows or down the columns and in ascending or descending order.
It has over 20 different sort methods not readily available in Excel.

They include sorting by numbers only, color
prefix, middle, suffix, random, reverse, no articles,
dates, decimal (ip and dewey), length and others.
Looks and works somewhat like the regular Excel sort utility.
It comes with a Word.doc install/use file.

It is - free - just email me and ask for it. (release 1.51)
Remove XXX from my email address.
'-----
Also, I have Excel VBA code that will enter non-duplicated
random numbers in a table arrangement.
I can post that if you are interested.

Jim Cone
San Francisco, USA
XX



"Twinkle17"
wrote in message
...
I have drawn up a table 10 columns by 30 rows and have a inserted a random
number between 1000 - 3000 in each cell using the RANDBETWEEN function.
Is there a way I can sort the table so that the lowest value appears in the
top left cell and the highest in the bottom right (ie. in order by rows and
then by columns)?
I hope this makes sense.
Alternatively how can I ensure that I do not have any duplicate numbers in
my selection?
Your assistance is appreciated.
Thank you