View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Pick Ref# randomly on an average

Interesting question. In C1 enter:
=RAND() and copy down

Pick another column, say E. In E1 enter:
=A1
In E2 enter:
=IF(COUNTIF($B$1:B2,B2) 1,"",A2) and copy down. we see:

4565 ABC 0.649004509 4565
6585 ABC 0.084606441
4314 ABC 0.131187935
5648 MNO 0.608040285 5648
6546 MNO 0.774962504
8974 XYZ 0.118081037 8974
1346 MNO 0.885189386
6584 XYZ 0.656284418
1366 ABC 0.580591399
4985 XYZ 0.199459732
1346 XYZ 0.105358721
5456 XYZ 0.939330574

As you see, column E "picks" a sample from each Ref#. Always the first
sample. But we sant a random sample so sort columns A thru C by C:

6585 ABC 0.658213589 6585
1346 XYZ 0.323008196 1346
8974 XYZ 0.043325857
4314 ABC 0.526986275
4985 XYZ 0.970380988
1366 ABC 0.037955305
5648 MNO 0.743534431 5648
4565 ABC 0.376891038
6584 XYZ 0.007517221
6546 MNO 0.462970369
1346 MNO 0.71457043
5456 XYZ 0.474824674


Now the data in column E is a random sample of the data in column A, one
sample for each Ref#
--
Gary''s Student - gsnu200832


"Kashyap" wrote:

Hi I have 2 columns as below..

Col A Col B

Ref# | Name
4565 | ABC
6585 | ABC
4314 | ABC
5648 | MNO
6546 | MNO
8974 | XYZ
1346 | MNO
6584 | XYZ
1366 | ABC
4985 | XYZ
1346 | XYZ
5456 | XYZ

I want to pick Ref# randomly on an average.

Say, in column B there are 40 ABC, 55 MNO, 80 XYZ, 10 PQR and so on.. Then I
need to pick a total on 20 ref# where I have ref# from all the Names on an
average.