Sort 6 teams by their first player

chuckf201

New Member
Joined
Nov 28, 2011
Messages
28
I have 6 teams that should formatted in 2 ways. First by players(3-4) in a team and then sort all teams by HCP (handicap) of player #1 using VBA.
Here is the tables in question:
Team 1​
HCP​
Dist​
Team 2​
HCP​
Dist​
Team 3​
HCP​
Dist​
Team 4​
HCP​
Dist​
Team 5​
HCP​
Dist​
Team 6​
HCP​
Dist​
KRAVITZ​
0.630​
1.646​
JUDD​
0.581​
2.841​
ANDERSON​
0.588​
3.149​
STARKEY​
0.489​
3.169​
MAHONEY​
0.587​
1.368​
KER​
0.728​
1.028​
FINGERMAN​
0.505​
3.119​
BARR​
0.489​
6.053​
MCKINZIE​
0.543​
3.957​
LYNCH​
0.467​
3.193​
JOHNSON​
0.565​
1.398​
ELLESTAD​
0.527​
1.314​
BYRD​
0.323​
1.366​
RALPH​
0.430​
3.445​
SMITH​
0.419​
2.483​
LEWIS-G​
0.462​
3.186​
HEARN​
0.347​
1.236​
MIERZWIAK​
0.290​
0.999​
looking at the teams, team 6 should be list first followed by Ker(.728) followed by Kravitz(.630) followed by Anderson(.588) followed by Mahoney(.587) followed by Judd(581) followed by Starkey(.489).
Sometime we have 4 man teams.
I've tried 2 nested for loops by doesn't quite do what I want.
I have Office365

Thanks.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Like this perhaps?

ABCDEFGHIJKLMNOPQR
1Team 1HCPDistTeam 2HCPDistTeam 3HCPDistTeam 4HCPDistTeam 5HCPDistTeam 6HCPDist
2KRAVITZ0.6301.646JUDD0.5812.841ANDERSON0.5883.149STARKEY0.4893.169MAHONEY0.5871.368KER0.7281.028
3FINGERMAN0.5053.119BARR0.4896.053MCKINZIE0.5433.957LYNCH0.4673.193JOHNSON0.5651.398ELLESTAD0.5271.314
4BYRD0.3231.366RALPH0.4303.445SMITH0.4192.483LEWIS-G0.4623.186HEARN0.3471.236MIERZWIAK0.2900.999
5
6
7Team 6HCPDistTeam 1HCPDistTeam 3HCPDistTeam 5HCPDistTeam 2HCPDistTeam 4HCPDist
8KER0.7281.028KRAVITZ0.6301.646ANDERSON0.5883.149MAHONEY0.5871.368JUDD0.5812.841STARKEY0.4893.169
9ELLESTAD0.5271.314FINGERMAN0.5053.119MCKINZIE0.5433.957JOHNSON0.5651.398BARR0.4896.053LYNCH0.4673.193
10MIERZWIAK0.2900.999BYRD0.3231.366SMITH0.4192.483HEARN0.3471.236RALPH0.4303.445LEWIS-G0.4623.186
Sheet1
Cell Formulas
RangeFormula
A7:R10A7=SORTBY(A1:R4,INDEX(A2:R2,CEILING(SEQUENCE(,COLUMNS(A2:R2)),3)-1),-1)
Dynamic array formulas.
 
Upvote 0
Solution
Like this perhaps?

ABCDEFGHIJKLMNOPQR
1Team 1HCPDistTeam 2HCPDistTeam 3HCPDistTeam 4HCPDistTeam 5HCPDistTeam 6HCPDist
2KRAVITZ0.6301.646JUDD0.5812.841ANDERSON0.5883.149STARKEY0.4893.169MAHONEY0.5871.368KER0.7281.028
3FINGERMAN0.5053.119BARR0.4896.053MCKINZIE0.5433.957LYNCH0.4673.193JOHNSON0.5651.398ELLESTAD0.5271.314
4BYRD0.3231.366RALPH0.4303.445SMITH0.4192.483LEWIS-G0.4623.186HEARN0.3471.236MIERZWIAK0.2900.999
5
6
7Team 6HCPDistTeam 1HCPDistTeam 3HCPDistTeam 5HCPDistTeam 2HCPDistTeam 4HCPDist
8KER0.7281.028KRAVITZ0.6301.646ANDERSON0.5883.149MAHONEY0.5871.368JUDD0.5812.841STARKEY0.4893.169
9ELLESTAD0.5271.314FINGERMAN0.5053.119MCKINZIE0.5433.957JOHNSON0.5651.398BARR0.4896.053LYNCH0.4673.193
10MIERZWIAK0.2900.999BYRD0.3231.366SMITH0.4192.483HEARN0.3471.236RALPH0.4303.445LEWIS-G0.4623.186
Sheet1
Cell Formulas
RangeFormula
A7:R10A7=SORTBY(A1:R4,INDEX(A2:R2,CEILING(SEQUENCE(,COLUMNS(A2:R2)),3)-1),-1)
Dynamic array formulas.

I like the approach but my sort seems off. Also, the teams will be 3 or 4 players and the cells are populated with VB, wich is not a big deal.

Team 1 HCP Dist Team 2 HCP Dist Team 3 HCP Dist Team 4 HCP Dist Team 5 HCP Dist Team 6 HCP Dist
2 KRAVITZ 0.63 1.646 JUDD 0.581 2.841 ANDERSON 0.588 3.149 STARKEY 0.489 3.169 MAHONEY 0.587 1.368 KER 0.728 1.028
3 FINGERMAN 0.505 3.119 BARR 0.489 6.053 MCKINZIE 0.543 3.957 LYNCH 0.467 3.193 JOHNSON 0.565 1.398 ELLESTAD 0.527 1.314
4 BYRD 0.323 1.366 RALPH 0.43 3.445 SMITH 0.419 2.483 LEWIS-G 0.462 3.186 HEARN 0.347 1.236 MIERZWIAK 0.29 0.999


Dist Team 4 HCP Dist Team 5 HCP 0 Team 1 HCP Dist Team 6 HCP Dist Team 2 HCP Dist Team 3 HCP
3.149 STARKEY 0.489 3.169 MAHONEY 0.587 2 KRAVITZ 0.63 1.368 KER 0.728 1.646 JUDD 0.581 2.841 ANDERSON 0.588
3.957 LYNCH 0.467 3.193 JOHNSON 0.565 3 FINGERMAN 0.505 1.398 ELLESTAD 0.527 3.119 BARR 0.489 6.053 MCKINZIE 0.543
2.483 LEWIS-G 0.462 3.186 HEARN 0.347 4 BYRD 0.323 1.236 MIERZWIAK 0.29 1.366 RALPH 0.43 3.445 SMITH 0.419
 

Attachments

  • ArrayForTeamSort.png
    ArrayForTeamSort.png
    147.5 KB · Views: 2
Upvote 0
I like the approach but my sort seems off.
Your formula points to columns A:R, but your data is in columns B:S.
Also, the teams will be 3 or 4 players ...
My data was in A1:R4. If there were 4 in a team, I'd change R4 to R5.

=SORTBY(A1:R4,INDEX(A2:R2,CEILING(SEQUENCE(,COLUMNS(A2:R2)),3)-1),-1)
 
Upvote 0
Your formula points to columns A:R, but your data is in columns B:S.

My data was in A1:R4. If there were 4 in a team, I'd change R4 to R5.

=SORTBY(A1:R4,INDEX(A2:R2,CEILING(SEQUENCE(,COLUMNS(A2:R2)),3)-1),-1)
My mistake. Now I need to learn what you did and why. My immediate MO is to go to VB.
Thanks for your help. we can close this.
 
Upvote 0
Thanks for your help. we can close this.
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,215,131
Messages
6,123,223
Members
449,091
Latest member
jeremy_bp001

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