rank / sort / split

domdc1

Board Regular
Joined
Apr 10, 2006
Messages
63
Helo all,
ill try to make this as painless as possible. I have 10000 names each with a ranking of either a,b,c or d. I have to equally split these individuals into groups so in the end i will have the same number of a,b,c and d in each group. I could take the long way and simply sort by ranking & divide accordingly. Any easy assistance will be greatly appreciated.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
For the purpose of this solution I will assume that Column A = Name, Column B = Rank, and all other columns are free. Also there are column headers

One solution without using vba is to sort by rank then in C2 place this formula =IF(B2=B1,1+C1,1) fill it down. This will produce a 1,2,3..,N that restarts for each rank. Then copy column C and paste special values. Then sort column C ascending (A-Z) this will produce something along the lines of
Excel Workbook
ABC
1NameRankSort
2Name 0001a1
3Name 0006b1
4Name 0003c1
5Name 0002d1
6Name 0004a2
7Name 0008b2
8Name 0019c2
9Name 0005d2
10Name 0009a3
11Name 0010b3
12Name 0031c3
13Name 0007d3
...


Then the just select number of sets to form your group size and deal with the in balance at the bottom.

This could also be done in VBA but it might not worth it if this something that you don't have to do very often.
 
Upvote 0
Solution
I will add one more twist. I want to cap the number or groups where the sort appears. For example if i want to sort only within groups 1-5 and gropus 6,7,8 or 9 need to be split within groups 1-5. As stated on the example below there are 2 names within group A which are to be sorted to sort 6 and 7 but i want them to be sorted within 1-5.

thanks again

Name Rank Sort
Name 0001 a 1
Name 0004 a 2
Name 0009 a 3
Name 00311 a 4
Name 00319 a 5 <---- should be 1
Name 00323 a 6 <---- should be 2
Name 00327 a 7 <---- should be 3
Name 0006 b 1
Name 0008 b 2
Name 00312 b 3
Name 00315 b 4
Name 00324 b 5
Name 0003 c 1
Name 0010 c 2
Name 0019 c 3
Name 0031 c 4
Name 00321 c 5
Name 00325 c 6 <---- should be 1
Name 003169 c 7 <---- should be 2
Name 00326 C 8 <---- should be 3
Name 00318 c 9 <---- should be 4
Name 0002 d 1
Name 0005 d 2
Name 0007 d 3
Name 00320 d 4
Name 00322 d 5
 
Last edited:
Upvote 0
Try the below solution instead of my previous solution. Should be easier as you don't have to sort and copy paste. If you use a pivot table you can to view the groups more easily.
Excel Workbook
ABCDEFG
1NameRankGroupTotal NamesNames per GroupNames per Rank per Group
2Name 0002CGroup 11000010025
3Name 0003CGroup 1
4Name 0004AGroup 1
5Name 0005AGroup 1
6Name 0007CGroup 1
7Name 0008DGroup 1
8Name 0009AGroup 1
...
Excel 2010
Cell Formulas
RangeFormula
E2=COUNTA(A:A)-1
G2=F2/4
C2="Group "&INT((COUNTIF(B$2:B2,B2)-1)/$G$2+1)
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,152
Members
452,891
Latest member
JUSTOUTOFMYREACH

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