Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello €“
I have a list of numbers in A1:A10, 1 through 10. From that list of numbers, what Ive got below is partially working, but I cannot seem to find how to generate a whole random # from that list€¦ Sub GenRand2() Dim myRange As Range Dim rO As Integer Dim Result As Double Set myRange = Worksheets("Sheet1") _ .Range("A1").CurrentRegion rO = myRange.Rows.Count Result = rO * Rnd() MsgBox Result End Sub Sincerely, Arturo |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub GenRand2()
Dim myRange As Range Dim rO As Integer Dim Result As Double Set myRange = Worksheets("Sheet1") _ .Range("A1").CurrentRegion rO = myRange.Rows.Count Randomize Result = Int((rO * Rnd) + 1) MsgBox Result End Sub "Arturo" schreef in bericht ... Hello - I have a list of numbers in A1:A10, 1 through 10. From that list of numbers, what I've got below is partially working, but I cannot seem to find how to generate a whole random # from that list. Sub GenRand2() Dim myRange As Range Dim rO As Integer Dim Result As Double Set myRange = Worksheets("Sheet1") _ .Range("A1").CurrentRegion rO = myRange.Rows.Count Result = rO * Rnd() MsgBox Result End Sub Sincerely, Arturo |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Assuming (a) by whole random # you mean a number from the myRange
range, and (b) CurrentRegion consists of a single column, use Result = myRange.Cells(Fix(rO * Rnd() + 1), 1) -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , says... Hello ¤=3F I have a list of numbers in A1:A10, 1 through 10. From that list of numbers, what I¤=3Fve got below is partially working, but I cannot seem to find how to generate a whole random # from that list¤=3F Sub GenRand2() Dim myRange As Range Dim rO As Integer Dim Result As Double Set myRange = Worksheets("Sheet1") _ .Range("A1").CurrentRegion rO = myRange.Rows.Count Result = rO * Rnd() MsgBox Result End Sub Sincerely, Arturo |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Generating random numbers | Excel Worksheet Functions | |||
Generating Random numbers. | Excel Discussion (Misc queries) | |||
generating random number list | Excel Worksheet Functions | |||
Generating Random Number from a set of numbers | Excel Discussion (Misc queries) | |||
generating random number as template | Excel Discussion (Misc queries) |