Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Random Generation
Hi. I am using VBA within Excel and have to generate the following: 4 Integers between 1 and 6 inclusive, none of which are the same. I can only use VBA to do this. Thanks, lot9 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Random Generation
Take a look he
http://www.mcgimpsey.com/excel/randint.html In article .com, "lordofthe9" wrote: I am using VBA within Excel and have to generate the following: 4 Integers between 1 and 6 inclusive, none of which are the same. I can only use VBA to do this. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Random Generation
Sub AA()
Dim v(1 To 6) As Long Dim i As Long Dim j As Long i = 0 Do j = Int(Rnd() * 6 + 1) If v(j) = 0 Then i = i + 1 v(j) = i End If Loop While i < 4 j = 0 For i = 1 To 6 If v(i) < 0 Then j = j + 1 Cells(j, 1).Value = i End If Next End Sub -- Regards, Tom Ogilvy "lordofthe9" wrote in message oups.com... Hi. I am using VBA within Excel and have to generate the following: 4 Integers between 1 and 6 inclusive, none of which are the same. I can only use VBA to do this. Thanks, lot9 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Random Generation
dim v(1 to 6) as Long
i = 0 do while i < 6 j = int(rnd()*6+1) if v(j) = 0 then i = i + 1 v(j) = i end if Next j = 0 for i = 1 to 6 if v(i) < 0 then j = j + 1 cells(j,1).Value = i end if Next "lordofthe9" wrote in message oups.com... Hi. I am using VBA within Excel and have to generate the following: 4 Integers between 1 and 6 inclusive, none of which are the same. I can only use VBA to do this. Thanks, lot9 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Random Generation
Thanks
|
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Random Generation
you could type the numbers 1 to 6 in one column and then =rand() on the next
column; to randomize, sort by the rand() column. A B 1| 1 =RAND() 2| 2 =RAND() 3| 3 =RAND() 4| 4 =RAND() 5| 5 =RAND() 6| 6 =RAND() then click on B1 and click on the sort ascending button. "lordofthe9" wrote: Hi. I am using VBA within Excel and have to generate the following: 4 Integers between 1 and 6 inclusive, none of which are the same. I can only use VBA to do this. Thanks, lot9 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
random letter generation | Excel Worksheet Functions | |||
Random List Generation | Excel Worksheet Functions | |||
Random Name Generation | Excel Worksheet Functions | |||
random number generation | Excel Worksheet Functions | |||
random number generation | Excel Programming |