Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
gilgamesh2006
 
Posts: n/a
Default excel random sample with criterion

I need to create a macro or function that will pull a random sample from
column B, but only when the criterion in column A is met. For example:
Column A Column B
A 123
A 456
A 789
B 234

I need to pull a random sample of the values in column b, but need the
ability to select the column A value. I was hoping for a button or formula
that i could move from sheet to sheet since we get a system generated list
each week.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary''s Student
 
Posts: n/a
Default excel random sample with criterion

Here is a neat trick:

The usual technique is to put =RAND() down column C and then sort by column
C. This will shuffle cols A & B. Instead put:

=(A1="A")*100 + RAND() in C1 and copy down. Now each sort (descending) will
put all the "A"'s at the top in a random order.

Just keep picking B1 after each sort.
--
Gary's Student


"gilgamesh2006" wrote:

I need to create a macro or function that will pull a random sample from
column B, but only when the criterion in column A is met. For example:
Column A Column B
A 123
A 456
A 789
B 234

I need to pull a random sample of the values in column b, but need the
ability to select the column A value. I was hoping for a button or formula
that i could move from sheet to sheet since we get a system generated list
each week.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
vezerid
 
Posts: n/a
Default excel random sample with criterion

Hi, if you only need to select one of the numbers in B:B, the following
*array* formula might also work for you (assuming data in A2:B8):

=SMALL(IF(A2:A8="A",B2:B8),INT(RAND()*COUNTIF(A2:A 8,"A"))+1)

As an array formula it must be entered with the key combination
Shift+Ctrl+Enter.

HTH
Kostis Vezerides

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
Find Numeric Criterion in Column & Return the Numeric Value from Row above Sam via OfficeKB.com Excel Worksheet Functions 6 April 27th 06 02:50 PM
Random Sample Without Duplication beccadawn0622 Excel Discussion (Misc queries) 3 January 25th 06 02:13 PM
How do I generate random lottery numbers in Excel? Mark1809 Excel Worksheet Functions 7 July 31st 05 07:23 PM
Generating Correlated Random Values in Excel Randy Excel Discussion (Misc queries) 2 January 16th 05 09:50 PM


All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"