Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / September 2007

Tip: Looking for answers? Try searching our database.

Randomly choosing a cell from a range of cells?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
emd - 25 Sep 2007 18:56 GMT
Scenario:

Worksheet A:

ID                CODE
1
1
1
2
3
3
4
4
4
...

Worksheet B:
ID             CODE
1                 AA
1                 DF
1                 HJ
1                 WE
1                 RT
1                 TY
2                 KL
2                 HO
2                 WO
2                 RO
2                 PG
2                 XM
2                 WK
2                 DF
...

I want to automatically fill in the CODE column in Worksheet A with a
random value chosen from CODE in Worksheet B; i.e. the 3 CODE values
for ID 1 in Worksheet A must be one of (AA, DF, HJ, WE, RT, TY) chosen
randomly.

Help!

Thanks
JE McGimpsey - 25 Sep 2007 20:19 GMT
One way:

   =INDEX(B!$B$2:$B$1000, MATCH(A2, B!$A$2:$A$1000, FALSE) + INT(RAND()
* COUNTIF(B!$A$2:$A$1000, A2)))

> Scenario:
>
[quoted text clipped - 38 lines]
>
> Thanks
emd - 25 Sep 2007 22:09 GMT
> One way:
>
>     =INDEX(B!$B$2:$B$1000, MATCH(A2, B!$A$2:$A$1000, FALSE) + INT(RAND()
> * COUNTIF(B!$A$2:$A$1000, A2)))

That is remarkably similar, but simpler, to the way I ended up doing
it.

Thanks very much.
Bernd P - 26 Sep 2007 13:10 GMT
Hello,

Can you really tolerate that your random lookup can appear more than
once?

Regards,
Bernd

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.