ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting players of cards (https://www.excelbanter.com/excel-programming/276595-re-sorting-players-cards.html)

Tom Ogilvy

Sorting players of cards
 
put 1 to 80 in A1:A80

in B1 to B80 put in

=Rand()

then sort both columns with column B as the sort key.

now you can take the firs "n" cells.

Regards,
Tom Ogilvy


"Pit" wrote in message
...
I have to draw some numbers from 1 to 80,i need to put a
form of application numbers, putting them to couples, they
are not had to repeat in the cycle of the program
Kindest regards
Peter




Pit

Sorting players of cards
 

-----Original Message-----
put 1 to 80 in A1:A80

in B1 to B80 put in

=Rand()

then sort both columns with column B as the sort key.

now you can take the firs "n" cells.

Regards,
Tom Ogilvy


Ok but i need a random beetwen 1 to 80, any vba code?
Thanks in advance
Pit

Tom Ogilvy

Sorting players of cards
 
That gives you a random between 1 and 80

Sub tester3()
Range("A1").Value = 1
Range("A2").Value = 2
Range("A1:A2").AutoFill _
Destination:=Range("A1:A80"), _
Type:=xlFillDefault
Range("B1:B80").Formula = "=Rand()"
Range("A1:B80").Sort Key1:=Range("B1")
varr = Range("A1:A10")
For i = 1 To 10
sStr = sStr & varr(i, 1) & ", "
Next
sStr = Left(sStr, Len(sStr) - 2)
' range("A1:B80").ClearContents
MsgBox sStr
End Sub

gives you 10 random picks.

--
Regards,
Tom Ogilvy


"Pit" wrote in message
...

-----Original Message-----
put 1 to 80 in A1:A80

in B1 to B80 put in

=Rand()

then sort both columns with column B as the sort key.

now you can take the firs "n" cells.

Regards,
Tom Ogilvy


Ok but i need a random beetwen 1 to 80, any vba code?
Thanks in advance
Pit





All times are GMT +1. The time now is 10:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com