Random Numbers

S

Steved

Hello from Steved

ok I am no thinking straight

What do I need to do please to have a number in a row 1 to 40
as an example below

1,23,9,25,33,40 each row needs to be 1 to 40 but number no more than once
six rows deep yes the other rows can have the same numbers as above or below

=INDEX(ROW($A$1:$F$10),RANK($H1,$H$1:$H$60))

=RAND() copied H1:H60
 
G

Gary''s Student

If you need to randomly select 6 numbers from the range 1-40 with no repeats:

1. Enter the numbers 1-40 into an un-used column
2. Enter =RAND() into the cells of the adjacent column
3. Sort the two columns by the RAND column

This will jumble the numbers 1-40 randomly. Just pick the first six numbers.
 
S

Steved

Hello Gary From Steved

Can your formula devoloped to display
6 columns across and 10 rows deep please.

Thankyou.
 
H

Harlan Grove

Steved wrote...
....
Can your formula devoloped to display
6 columns across and 10 rows deep please. ....
....

You don't need steps 1 or 3. All you need is a range of 60 cells (10*6)
all containing =RAND(). If that range were named PRNA and the top-left
cell of your 10 by 6 result range were C5, enter the following formula
in C5.

C5:
=COUNTIF(PRNA,"<="&INDEX(PRNA,ROWS($C$5:C5)*6-COLUMNS($C$5:C5)+1))

Select C5 and fill right into D5:H5. Then select C5:H5 and fill down
into C6:H14.
 
G

Gary''s Student

Yes.

In my method we are selectimg 6 random numbers in a column. Select all six
numbers and push copy.

Go to the place in the first row and paste/special with the transpose mark
checked.

This will paste the column into your first row. Now we need to fill rows 2-10
and we will do the same thing
1. re-calculate the random numbers (CNTRL-ALT-F9)
2. re-sort the columns to get fresh random digits
3. copy/paste into the next row
 
S

Steved

Hello Harlan from Steve

I think i'm missing something here

I followed what you put below naming the range PNRA

ok =RAND() are in cell A1:F10 I highlighted and then I
Insert Name Define

please I am lost where do I put the below


COUNTIF(PRNA,"<="&INDEX(PRNA,ROWS($C$5:C5)*6-COLUMNS($C$5:C5)+1))

Also do I change your $C$5:$C$5 to $A$1:$A$1

ok also please what is require to reconize the number between 1 to 40.

Thankyou.
 
R

Ragdyer

You can try this:

Enter
=RAND()
In AA1 and drag across to BN1,
Then down to BN10,
So you have a 40 column by 10 row array of random numbers.

Then, enter this formula anywhere you wish:

=INDEX(ROW($A1:$A40),RANK(AA1,$AA1:$BN1))

Now, copy this formula across 6 columns.
Then, copy down 10 rows.

This should give you what you're looking for.
You'll get a new set of numbers with each hit of <F9>.
 
H

Harlan Grove

...
....
I followed what you put below naming the range PNRA

ok =RAND() are in cell A1:F10 I highlighted and then I
Insert Name Define

please I am lost where do I put the below


COUNTIF(PRNA,"<="&INDEX(PRNA,ROWS($C$5:C5)*6-COLUMNS($C$5:C5)+1))

First, you're missing the initial equal sign.

I may have misunderstood your question. Looks like you want 10 samples of 6
numbers each of which is drawn without replacement from 1-40. If so, then
you still don't need anything more than a 40 cell range each cell in which
containing =RAND(), which I'll still call PRNA. I'll further assume that
PRNA is 40 rows in a single column.

Then, in another range WHICH YOU MUST CHOOSE (but for my convenience, I'll
continue to use C5:H14, so in my case, the cells containing the =RAND()
formula don't overlar C5:H14), select C5:H5 and enter the following array
formula.

C5:H5 [array formula]:
=COUNTIF(PRNA,"<="&TRANSPOSE(OFFSET(PRNA,INT(35*RAND()),0,6,1)))

Select C5:H5 and fill down into C6:H14.
 
S

Steved

Hello Ragdyer from Steved

Excellent thankyou.

Ragdyer said:
You can try this:

Enter
=RAND()
In AA1 and drag across to BN1,
Then down to BN10,
So you have a 40 column by 10 row array of random numbers.

Then, enter this formula anywhere you wish:

=INDEX(ROW($A1:$A40),RANK(AA1,$AA1:$BN1))

Now, copy this formula across 6 columns.
Then, copy down 10 rows.

This should give you what you're looking for.
You'll get a new set of numbers with each hit of <F9>.
 
S

Steved

Hello Harlan from Steved

ok put =RAND() in A1:A40
Then Insert, Name, Define, and typed PRNA then add and ok

I then

C5:H5 [array formula]: using Ctrl Shift Enter

=COUNTIF(PRNA,"<="&TRANSPOSE(OFFSET(PRNA,INT(35*RAND()),0,6,1)))

Select C5:H5 and fill down into C6:H14.

Done all off the above pushed F9 and on the same row I get the same number
twice.

Am I missing something here.

Cheers



Harlan Grove said:
...
....
I followed what you put below naming the range PNRA

ok =RAND() are in cell A1:F10 I highlighted and then I
Insert Name Define

please I am lost where do I put the below


COUNTIF(PRNA,"<="&INDEX(PRNA,ROWS($C$5:C5)*6-COLUMNS($C$5:C5)+1))

First, you're missing the initial equal sign.

I may have misunderstood your question. Looks like you want 10 samples of 6
numbers each of which is drawn without replacement from 1-40. If so, then
you still don't need anything more than a 40 cell range each cell in which
containing =RAND(), which I'll still call PRNA. I'll further assume that
PRNA is 40 rows in a single column.

Then, in another range WHICH YOU MUST CHOOSE (but for my convenience, I'll
continue to use C5:H14, so in my case, the cells containing the =RAND()
formula don't overlar C5:H14), select C5:H5 and enter the following array
formula.

C5:H5 [array formula]:
=COUNTIF(PRNA,"<="&TRANSPOSE(OFFSET(PRNA,INT(35*RAND()),0,6,1)))

Select C5:H5 and fill down into C6:H14.
 
H

Harlan Grove

...
....
=COUNTIF(PRNA,"<="&TRANSPOSE(OFFSET(PRNA,INT(35*RAND()),0,6,1)))
....

Sorry, I screwed this up. Swap the 6 and 1 arguments, so

=COUNTIF(PRNA,"<="&TRANSPOSE(OFFSET(PRNA,INT(35*RAND()),0,1,6)))
 
S

Steved

Hello Harlan from Steved

Harlan done as discribed below but still have the issue offsame number twice
omn the same line

in this case row 8 i've 13 twice and row 10 I have 24 twice.

Is it possible please to have this issue where their are no doubles.
Thankyou for your patience.
 
B

Bernd Plumhoff

Hello,

I suggest to insert a VBA module with my UDF function UniqRandInt() (see
www.sulprobil.com),
then select cells A1:F1 enter
=UniqRandInt(40, false)
as array formula (CTRL+SHIFT+ENTER)
and copy this down to A10:F10.

I admire elegant worksheet function solutions, but if you like to have a
general and robust solution, a thoroughly tested UDF function might be the
answer of your choice (don't trust my function, test it!).

HTH,
Bernd
 
R

RagDyeR

You're *not* looking for random numbers, since true randomness accepts the
possibility of duplication, since each item has an equal chance of occurring
at each interval.

You're looking for a random *order* of specific items (numbers 1 to 40).

So, you therefore need, first of all, the specific items so that they can be
rearranged randomly.
That's the numbers of the rows, 1 to 40, making the construction of an
actual list unnecessary.

Next, the list is rearranged virtually, by accessing the 40 columns of
random numbers and ranking these numbers, where this ranking is mirrored in
the indexed row numbers.
Even if these *true* random numbers are duplicated, and they are ranked
*equally*, since they designate the row numbers, there *cannot* be a
duplicated return, since there are *no* duplicate row numbers existing.

And since each row must be independent of the other rows, so that
duplication is avoided, you need a separate row of random numbers to be
ranked differently from the others.

Therefore, my hat is off to Harlan if he can accomplish this scenario
*without* the existence of this 40 column by 10 row array of random numbers.

--

Regards,

RD
----------------------------------------------------------------------------
-------------------
Please keep all correspondence within the Group, so all may benefit !
----------------------------------------------------------------------------
-------------------


Hello Harlan from Steved

Harlan done as discribed below but still have the issue offsame number twice
omn the same line

in this case row 8 i've 13 twice and row 10 I have 24 twice.

Is it possible please to have this issue where their are no doubles.
Thankyou for your patience.
 
S

Steved

Hello Bernd from Steved

I've put your UDF in VBA and Copied =UniqRandInt(40, false)

ok it has #NAME?

What have I not done right please

I presume F9 to execute

Thankyou.
 
S

Steved

Hello RagDyeR from Steved

I am using your formula and so far I have'nt got any doubles.

I've tried it several times yet to produce a double.

So yes I'm Using it.

Thankyou
 
D

Dave Peterson

Did you put it in a general module?
Hello Bernd from Steved

I've put your UDF in VBA and Copied =UniqRandInt(40, false)

ok it has #NAME?

What have I not done right please

I presume F9 to execute

Thankyou.
 
D

Dave Peterson

It sounds like you pasted it under the ThisWorkbook module.

Once you get to the VBE (alt-f11 is nice)
hit ctrl-r (to see the project explorer)
find your project
rightclick on it
Insert|Module

Paste it there.

(look under the ThisWorkbook module and delete it from there if I guessed
right.)

Then back to excel and recalculate.
 
S

Steved

Thanks very much Dave

Yes I carried out what you described and yes it created Random Numbers.

I still have a Issue and that is when pushing F9 it will not recalculate.

And to Bernd if you get to read this yes I get a double on the same line

Line 1 No 7, Line 4 No 35, Line 6 No 12, Line 8 No 40, and line 10 12

As pasted below.

26 40 17 12 7 7
29 22 24 12 13 31
1 31 33 29 2 17
35 32 15 39 35 3
38 15 21 31 3 24
19 12 25 26 11 12
34 33 24 40 37 10
28 40 10 22 5 40
28 1 24 5 5 32
12 2 12 16 13 38

Thanks once again Dave.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top