Best way to make all-time leading scorers sheet from multiple sheets

confuxion

New Member
Joined
Aug 17, 2024
Messages
14
Office Version
  1. 2019
Platform
  1. Windows
So I've gone through the arduous process of collecting (in Excel) 20 season's worth of individual scoring stats for the HS hockey team my son plays for. Every season is contained in it's own sheet, with individual stats for each player. I'm looking for the best approach to creating an additional sheet that compiles an all-time leading scorers list among those 20 seasons; one that will keep the manual data-entry to a minimum. Given that high school is 4 years, many players appear on upwards of 4 different sheets. This is more about the approach in trying to collect every player and their associated career stats onto one sheet. My initial thought is to use VLOOKUPS on player names across all 20 sheets, but the best way to do this escapes me. Maybe this is simpler than I think. Thanks in advance for any tips/ideas!
 

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
Welcome to the MrExcel board!

This is probably best as a macro job rather than formulas. Would that be acceptable?
If so, could you make up say 3 small dummy "season" worksheets and then manually fill out the results sheet that you would like produced from that data. Post all 4 small sheets with the tool mentioned below.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.

(If you have trouble with XL2BB review the "XL2BB Icons greyed out" link in the 'Known XL2BB issues' section near the top of theXL2BB Instructions page linked above.)
 
Upvote 0
2023-2024-u32-varsity-hockey-stats.xlsx
ABCDEF
12021 TOTALS
2Scoring
3PlayerGaGAPTSPIM
4Wayne Gretzky2055102
5Bobby Orr181672312
6Mario Lemieux19423276
7Martin St. Louis2049137
8John LeClair1733615
9
10TOTALS2032477942
2021
Cell Formulas
RangeFormula
E4:E8E4=C4+D4
C10:F10C10=SUM(C4:C8)
2023-2024-u32-varsity-hockey-stats.xlsx
ABCDEF
12022 TOTALS
2Scoring
3PlayerGaGAPTSPIM
4Wayne Gretzky191525404
5Bobby Orr12710176
6Mario Lemieux151414288
7Martin St. Louis20826342
8John LeClair181081825
9Jarri Kurri20714216
10Mark Messier1915112645
11
12TOTALS207610818496
2022
Cell Formulas
RangeFormula
E4:E10E4=C4+D4
C12:F12C12=SUM(C4:C10)
2023-2024-u32-varsity-hockey-stats.xlsx
ABCDEF
12023 TOTALS
2Scoring
3PlayerGaGAPTSPIM
4Wayne Gretzky1955102
5Martin St. Louis201672312
6John LeClair15423276
7Mark Messier1949137
8Connor McDavid2033615
9Sidney Crosby201218306
10Connor Bedard18716237
11Mack Celebrini1648125
12
13TOTALS20558914460
2023
Cell Formulas
RangeFormula
E4:E11E4=C4+D4
C13:F13C13=SUM(C4:C11)
2023-2024-u32-varsity-hockey-stats.xlsx
ABCDEF
1CAREER LEADERS
2Scoring
3PlayerGaGAPTSPIM
4Wayne Gretzky0
5Martin St. Louis0
6John LeClair0
7Mark Messier0
8Connor McDavid0
9Sidney Crosby0
10Connor Bedard0
11Mack Celebrini0
12Bobby Orr0
13Mario Lemieux0
14Jari Kurri0
15Mark Messier0
16
17TOTALS0000
CAREER
Cell Formulas
RangeFormula
E4:E15E4=C4+D4
C17:F17C17=SUM(C4:C11)
 
Upvote 0
I think I did that correctly.
You have used XL2BB correctly. (y)

However, you have not manually filled out the results sheet with the results that you would want. Can you do that on the CAREER sheet and post that one again, adding any explanation about how you got those results so that helpers who know nothing about the sport might still be able to assist?
 
Upvote 0
I manually added the formulas in for the "Ga" (Games) column for the first 3 players to give you an idea of what I'm doing. But what that involved was hitting the equals button, then manually going through each sheet and selecting the amount of "Ga" for the corresponding player, adding a + symbol after each instance, then hitting Enter to achieve the total. Imagine doing this process for each player, maybe 200 players total, over 20 sheets, each representing a given season. It's doable, given that no player will have appeared in more than 4 sheets (seasons), but I just wondered if there was a better way. For example, something that:

1) Loops through all 20 sheets, grabs all the unique names, then dumps them on the Career sheet, to start...
2) Then, for each player listed, a formula/macro looks through all 20 sheets to find that player's corresponding stats and totals them on the Career sheet.

2023-2024-u32-varsity-hockey-stats.xlsx
ABCDEF
1CAREER LEADERS
2Scoring
3PlayerGaGAPTSPIM
4Wayne Gretzky58253560
5Martin St. Louis60284270
6John LeClair50173451
7Mark Messier0
8Connor McDavid0
9Sidney Crosby0
10Connor Bedard0
11Mack Celebrini0
12Bobby Orr0
13Mario Lemieux0
14Jari Kurri0
15Mark Messier0
16
17TOTALS701111810
CAREER
Cell Formulas
RangeFormula
B4:D4B4='2021'!B4+'2022'!B4+'2023'!B4
B5:D6B5='2021'!B7+'2022'!B7+'2023'!B5
E4:E15E4=C4+D4
C17:F17C17=SUM(C4:C11)
 
Upvote 0
I may just have to do it the way that I described in my last post. It will take some time and carpal-tunnel syndrome to do for 200+ players over the course of 20 seasons. Was just looking for something smarter than I'm capable of.
 
Upvote 0
Hi confuxion,

Using Power Query is the easiest way in my opinion to do this.

Power Query:
let
    Source = Excel.Workbook(File.Contents("C:\Users\Book1.xlsx"), null, true), // add your file location
    #"Filtered" = Table.SelectRows(Source, each ([Kind] = "Sheet") and ([Item] <> "CAREER"))[Data],
    All_Data = Table.Combine(List.Transform(#"Filtered", (x)=> Table.PromoteHeaders(Table.Skip(x,2)))),
    Removed_null_Totals = Table.SelectRows(All_Data, each ([Player] <> null and [Player] <> "TOTALS")),
    cols = List.Skip(Table.ColumnNames(Removed_null_Totals),1),
    #"Grouped Rows" = Table.Group(Removed_null_Totals, {"Player"}, {{"x", each Table.FromRows({List.Accumulate(cols, {}, (s,c)=> s & {List.Sum(Table.Column(_,c))})}, cols)}}),
    Result = Table.ExpandTableColumn(#"Grouped Rows", "x", cols)
in
   Result

1723886663249.png


Converting your data to tables is easier to manipulate - if so, the M code should be updated.

Regards
 
Upvote 0
Alex78, thanks for your reply. Just so I'm clear, is the macro code you included responsible for totaling each players career stats from the 3 sheets, or is that just the code to convert the data on the Career sheet to a table? Also, do you recommend converting the data in each sheet to tables, not just the Career sheet? Sorry, this is a bit above my pay-grade.
 
Upvote 0
Give this macro a try with a copy of your workbook. I have assumed that the 'CAREER' sheet has been created and has those headings shown in rows 1:3.
No need for formal tables for this code.
If another sheet is added in the future just run the code again.

VBA Code:
Sub Career_Stats()
  Dim d As Object
  Dim a As Variant, Bits As Variant
  Dim ws As Worksheet
  Dim i As Long
 
  Set d = CreateObject("Scripting.Dictionary")
  d.CompareMode = 1
  For Each ws In Worksheets
    If ws.Name Like "####" Then
      a = ws.Range("A4", ws.Range("A" & Rows.Count).End(xlUp).Offset(-2)).Resize(, 4).Value
      For i = 1 To UBound(a)
        If d.exists(a(i, 1)) Then
          Bits = Split(d(a(i, 1)))
          d(a(i, 1)) = Bits(0) + a(i, 2) & " " & Bits(1) + a(i, 3) & " " & Bits(2) + a(i, 4)
        Else
          d(a(i, 1)) = a(i, 2) & " " & a(i, 3) & " " & a(i, 4)
        End If
      Next i
    End If
  Next ws
  Application.ScreenUpdating = False
  With Sheets("CAREER")
    .UsedRange.Offset(3).EntireRow.Delete
    With .Range("A4").Resize(d.Count, 2)
      .Value = Application.Transpose(Array(d.Keys, d.Items))
      .Columns(2).TextToColumns DataType:=xlDelimited, Space:=True, Other:=False
      .Offset(, 4).Resize(, 1).FormulaR1C1 = "=RC[-2]+RC[-1]"
    End With
    With .Range("A" & Rows.Count).End(xlUp).Offset(2)
      .Value = "TOTALS"
      .Offset(, 2).Resize(, 4).FormulaR1C1 = "=SUM(R4C:R[-1]C)"
      .EntireRow.Font.Bold = True
    End With
    .UsedRange.Columns.AutoFit
  End With
  Application.ScreenUpdating = True
End Sub

Here is my 'CAREER' sheet after running the above code with your 3 year sheets. If the results need ordering in some way then give details.

confuxion.xlsm
ABCDEF
1CAREER LEADERS
2Scoring
3PlayerGaGAPTSPIM
4Wayne Gretzky58253560
5Bobby Orr30231740
6Mario Lemieux34183755
7Martin St. Louis60284270
8John LeClair50173451
9Jarri Kurri2071421
10Mark Messier38192039
11Connor McDavid20336
12Sidney Crosby20121830
13Connor Bedard1871623
14Mack Celebrini164812
15
16TOTALS1632444070
CAREER
Cell Formulas
RangeFormula
E4:E14E4=C4+D4
C16:F16C16=SUM(C$4:C15)
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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