A Random Challenge

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
Here’s a little challenge for everyone:

Object
Enter formula(s) in each of 6 cells A1:F1 such that when the worksheet is calculated it produces a random integer between 0 and 9 in each cell with no repeats.

Rules
Formulas only, no macros/vba
Shortest formula wins (total number of characters over all 6 cells)
Random numbers must be generated equally over a large number of trials

Good Luck!
 
HI Lewiy

In A1:
Code:
=SMALL(IF(COUNTIF(B1:$G$1,ROW($1:$10)-1)<>1,ROW($1:$10)-1),1+INT(RAND()*(10+COLUMN()-COLUMN($G$1))))
This in an array formula and so MUST be entered with CTRL+SHIFT+ENTER and not just ENTER.
Copy right till F1

Leave G1 empty

Kind regards
PGC
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Barry, your solution only produces values from 0-5.

Not, if correctly implemented. As stated above, you have to copy =RAND() in A2 across to J2


For a single formula solution, using pgc01's formula from the link I posted above, shortened as far as I can......

in A1

=SMALL(IF(COUNTIF(B1:$G1,ROW(1:10)-1)=0,ROW(1:10)-1),1+INT(RAND()*(COLUMN()+4)))

confirm with CTRL+SHIFT+ENTER, copy across to F1, G1 should be blank
 
Upvote 0
But B is not a random number in it's own right, it is always 1 more than A
 
Upvote 0
Hi Lewiy

I have an error in my formula, it generates only the numbers 0-8. However there is no need for me to correct it, since I see that Barry already posted a perfect formulation of the formula.

Thanks Barry.

Kind regards
PGC
 
Upvote 0
Thanks PGC and Barry, I think together you've cracked this one. Good job!
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top