+ Reply to Thread
Results 1 to 8 of 8

Creating a formula to do a teammate count

  1. #1
    Registered User
    Join Date
    08-26-2021
    Location
    Melbourne, Australia
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Creating a formula to do a teammate count

    I have a long list of teams similar to the list in columns A,B,C of this example.

    I wish to create a count of how many times each pair of players appear in a premiership team together as per columns F,G,H of the example.

    Note that these are cricket teams of eleven players, I have three teams listed here in the example but some 50+ teams to apply this formula to.

    Can anyone suggest a way to do this as I have not been able to find anything similar in the forum??
    Attached Files Attached Files

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,407

    Re: Creating a formula to do a teammate count

    Hello Midday259. Welcome to the forum.

    Try this. It returns what you are expecting in column H.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Edit: I forgot to mention, before entering that formula above fill in the row headers in column A by:
    1. selecting A2:A34
    2. hitting the F5 function key (GoTo)
    3. clicking the Special... button
    4. selecting Blanks
    5. hit Enter


    All the blank cell will be selected.

    Then:
    1. type =
    2. then the up arrow key
    3. then while holding down the Ctrl key hit enter
    4. that will fill copy down the missing row headers
    Last edited by FlameRetired; 11-07-2021 at 02:53 PM.
    Dave

  3. #3
    Registered User
    Join Date
    08-26-2021
    Location
    Melbourne, Australia
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: Creating a formula to do a teammate count

    Thanks for replying Dave. That formula is very helpful, but it seems I may not have explained my requirements properly.

    I not only need to create the count in column H, but also the lists of names in columns F & G. I did this manually in my example (and only did about a quarter of them) simply to show what i needed. Is this something I can do with formulas? It has been suggested to me that I may need a Pivot Table but I have zero experience with them.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,363

    Re: Creating a formula to do a teammate count

    VBA offering: matrix replaces columns F:H

    Please Login or Register  to view this content.
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Creating a formula to do a teammate count

    John's VBA approach is fully automated and may well provide the best performance, which may begin to matter as you add more matches. However, just in case you prefer not to use a VBA approach, here is a "semi-manual" / "semi-automatic" approach to creating all combinations (in the mathematical sense) of two players.

    ONE TIME SETUP
    1. Create a new blank worksheet. I called it "Comb" for combinations.
    2. Create row-1 headers:
      A1: Unique player list
      B1: Player-1
      C1: Player-2
      D1: Unique
    3. In G2 (compute necessary rows): =(COUNTA(A:A)-1)^2
    4. In G3 (combinations): =COMBIN(COUNTA(A:A)-1, 2)
    5. In B2: =INDEX($A$2:$A$30, (INT(ROW()-2)/COUNTA($A$2:$A$30))+1)
    6. In C2: =IF(B2=0, 0, INDEX($A$2:$A$30, MOD(ROW()-2, COUNTA($A$2:$A$30))+1))
    7. In D2: =IF(B2<C2, "keep", "")

    Your "Comb" worksheet (after step-5 below) should now appear as follows with col-B and col-C listing all required combinations of players:

    team mate.png

    AFTER ADDING MATCHES TO SHEET1
    1. Copy Sheet1!C:C to Comb!A:A
    2. Select Comb!A:A
    3. Ribbon > Data > Remove Duplicates (if there is a warning then select "Continue with current selection." > Select "My data has headers" > OK.
    4. With your sample data there should now be 25 unique players in col-A. Necessary rows in G2 should be 625 and Combinations (selecting 2 from the col-A list with order irrelevant) should be 300.
    5. Select Comb!B2:D2 and drag down to cover G2 (=625) rows
    6. Filter col-D on "keep". With your sample data you should now have 300 rows selected representing all possible combinations of 2 players.
    7. With the filter in place, select B2:C625 then copy to Sheet1!F2.

    You should now have all 300 combinations in col-F:G of sheet1.

    SUMMARY

    I included my formula in column-I and, for comparison purposes, Dave's formula (adjusted to not use unique() as I don't have O-365) in column-J.

    My formula I2 copied down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This formula yields the same results as Dave's. My formula does not require the row headers that Dave requested, but Dave's formula is significantly less complex and I'm sure will perform more efficiently.

    My semi-manual method of generation combinations described above will of course work equally well with Dave's approach.

    Finally, just a note, my Sheet1 column I formula will require adjustment (beyond extending ranges) when further matches are added. I won't bother pursuing that unless there is further interest.

    The attached workbook includes all of the above.
    Attached Files Attached Files
    Last edited by GeoffW283; 11-08-2021 at 04:40 PM.
    Geoff

    Did I help significantly? If you wish, click on * Add Reputation to say thanks.
    If your problem has been resolved please select ?Solved? from the Thread Tools menu

  6. #6
    Registered User
    Join Date
    08-26-2021
    Location
    Melbourne, Australia
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: Creating a formula to do a teammate count

    Thanks heaps to everyone. I will work to adapt these into my main spreadsheet which has many more teams & players.

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,407

    Re: Creating a formula to do a teammate count

    You may want to check back in from time to time.

    I haven't given up on this one yet.

    Although even if this can be done by formula I suspect John's VBA solution is going to be your best bet.

  8. #8
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Creating a formula to do a teammate count

    If you do intend to pursue my approach then obviously change all the 34's in formulas to exactly cover the additional matches. The {1,2,3} arrays needs to be extended to exactly equal the number of matches (there's more elegant ways to do this if you will have a large number of matches (maybe like row(1:50))).

    Anyway, thanks for the feedback and rep and good luck whichever approach you use!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. creating table of data link from a count formula
    By magicmackie21 in forum Excel General
    Replies: 1
    Last Post: 08-30-2019, 03:55 AM
  2. Creating a weekly count.
    By SafetyKeetch in forum Excel General
    Replies: 5
    Last Post: 09-14-2015, 09:12 AM
  3. Creating a Date Count Formula
    By tdsmith14 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-22-2013, 01:11 PM
  4. [SOLVED] Need help with creating formula to count cells based on 2 criterias
    By Titleistseemore in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-11-2013, 03:00 AM
  5. [SOLVED] creating a count formula that looks at multiple criteria
    By jdrobin in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-09-2013, 07:16 PM
  6. Replies: 1
    Last Post: 06-26-2012, 05:02 PM
  7. Creating a Count formula
    By Shelyna in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-30-2006, 05:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1