Counting Wins And Losses

Daviboy30

New Member
Joined
Nov 7, 2021
Messages
33
Office Version
  1. 2019
Platform
  1. MacOS
I'm running a scoresheet for my league and I need to track each player's wins and losses record throughout the season, including the previous season, so that I can assign a proper player ranking. If a player wins or loses 7 out of 10 matches his ranking goes up or down, depending on how he (or she) does. Players often do not play every week, but I still need to track their wins and losses through multiple seasons. More often than not player ranking don't change because they don't meet the 7 out of ten threshold, but when they do, I want the spreadsheet to automatically post the new ranking.

In the attached Mini-sheet example Joe's ranking remained the same because over a period of 13 weeks he played 10 matches, but did not meet the 7 out of 10 wins or losses threshold. Meanwhile Jack's ranking went from 6 up to 7 because over a period of 15 weeks he played 10 matches and won 7 of them. In Mary's example, her ranking went down because over a period of 14 weeks she played 10 matches and lost 7 times. If a player rank goes up then the counting of wins and losses starts fresh.

The problem I'm having is how to automatically track a player's last 10 matches whether he plays the matches in 10 weeks, 10 months or even 10 years.

IFTestBook2.xlsx
ABCDEFGHIJKLMNOPQRSTUVW
3PlayerCurrent RankCurrent WinsCurrent LossesNew Rank1/11/81/151/221/292/52/122/192/263/53/123/193/264/24/94/164/234/30
4Joe4654WWWLLWWLWWWLWL
5Jack6737WWLWWLWWLWW
6Mary3372LWLWLLLWWLLL
Sheet1
Cell Formulas
RangeFormula
C4C4=COUNTIF(K4:W4,"W")
D4:D5D4=COUNTIF(H4:W4,"L")
E4:E6E4=IF(C4>6, B4+1, IF(D4>6, B4-1, IF(B4=2, 2, IF(B4=3, 3, IF(B4=4, 4, IF(B4=5, 5, IF(B4=6, 6, IF(B4=7, 7))))))))
C5C5=COUNTIF(I5:W5,"W")
C6C6=COUNTIF(J6:W6,"W")
D6D6=COUNTIF(J6:W6,"L")
 

Attachments

  • Screen Shot 2021-11-07 at 4.52.18 PM.png
    Screen Shot 2021-11-07 at 4.52.18 PM.png
    99.1 KB · Views: 18
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I created a new sheet with all the Wins and Losses data entered on one row for each player. When I typed a W in the first column under Joe (G5), I still get the error message reported before on the following line:

a = Split(" " & Join(Application.Index(Range(Cells(r, LastReset + FirstDataCol), Cells(r, lc)).Value, 1, 0)))

The following are the values you requested on post #29:
r = 5
LastReset = 0
FirstDataCol = 7
lc = 7

IFTestBook6-Peter.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCWCXCYCZDADBDCDDDEDFDGDHDIDJDKDLDMDNDODPDQDRDSDTDUDVDWDXDYDZEAEBECEDEEEFEGEHEIEJEKELEMENEOEPEQERESETEUEVEWEXEYEZFAFBFCFDFEFFFGFHFIFJFKFLFMFNFOFPFQFRFSFTFUFV
12021
2JulyAugustSeptember
3PlayerCurrent RankCurrent WinsCurrent LossesNew RankLast ResetTuWeThFrSaSuMoTuWeThFrSaSuMoTuWeThFrSaSuMoTuWeThFrSaSuMoTuWeThFrSaSuMoTuWeThFrSaSuMoTuWeThFrSaSuMoTuWeThFrSaSuMoTuWeThFrSaSuMoTuWeThFrSaSuMoTuWeThFrSaSuMoTuWeThMoTuWeThFrSaSuMoTuWeThFr
4First Name1314151617181920212223242526272829303112345678910111213141516171819202122232425262728293031123456789101112131415161718192021222324252627282930192021222324252627282930
5Joe610W
6Jon400
7Rich200
Sheet1
Cell Formulas
RangeFormula
C5:C7C5=LEN(RIGHT(CONCAT(G5:AVY5),10))-LEN(SUBSTITUTE(RIGHT(CONCAT(G5:AVY5),10),"W",""))
D5:D7D5=LEN(RIGHT(CONCAT(G5:AVZ5),10))-C5
 
Upvote 0
I created a new sheet with all the Wins and Losses data entered on one row for each player. When I typed a W in the first column under Joe (G5), I still get the error message reported before on the following line:

a = Split(" " & Join(Application.Index(Range(Cells(r, LastReset + FirstDataCol), Cells(r, lc)).Value, 1, 0)))

The following are the values you requested on post #29:
r = 5
LastReset = 0
FirstDataCol = 7
lc = 7
Thank you for those details.
I do get that error if I delete a single entry in G5 but not when I enter it. I don't see that it should be the case but perhaps it could relate to you using a Mac.
Can you try the version below but please try it with this single-result-per-week layout that I have shown below* as I have not attempted to adapt to multiple results yet.
I know that you have said 2 results per day is a must, but one step at a time for this development please!

* You can copy this layout to a blank worksheet by clicking this icon
1636926993303.png
at the top left of my mini-sheet below, select cell A1 in a blank worksheet and Paste.

Also, please do not enter those formulas in columns C & D. As I have stated before: They will not work to correctly give you current wins and losses.

Daviboy30_1.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
2
3PlayerCurrent RankCurrent WinsCurrent LossesNew RankLast Reset
4First Name1234567891011121314151617181920
5Joe
6Jon
7Rich
P32 (2)


New code to try in this worksheet's module.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim a As Variant
  Dim W As Long, L As Long, K As Long, i As Long, j As Long, r As Long, wk As Long, lc
  Dim OldRank As Long, NewRank As Long, UpDown As Long, LastReset As Long
 
  Const FirstDataRow As Long = 5
  Const FirstDataCol As Long = 7
  Const CurrentRankCol As Long = 2
 
  If Target.CountLarge = 1 And Target.Column >= FirstDataCol And Target.Row >= FirstDataRow Then
    r = Target.Row
    LastReset = Cells(r, CurrentRankCol + 4).Value
    wk = Target.Column - FirstDataCol + 1
    If wk > LastReset Then
    OldRank = Cells(r, CurrentRankCol).Value
    lc = Cells(r, Columns.Count).End(xlToLeft).Column + 1
    If lc <= Target.Column Then lc = Target.Column + 1
    a = Split(" " & Join(Application.Index(Range(Cells(r, LastReset + FirstDataCol), Cells(r, lc)).Value, 1, 0)))
      For i = 1 To UBound(a)
        Do
          If Len(a(i + j)) > 0 Then
            If UCase(a(i + j)) = "W" Then
              W = W + 1
            Else
              L = L + 1
            End If
            K = K + 1
            If K = 10 Then
              If W > 6 Then
                UpDown = UpDown + 1
                LastReset = LastReset + i + j
                i = i + j
              ElseIf L > 6 Then
                UpDown = UpDown - 1
                LastReset = LastReset + i + j
                i = i + j
              End If
              Exit Do
            End If
          End If
          j = j + 1
        Loop Until i + j = UBound(a) + 1 Or K = 10
        If i + j = UBound(a) + 1 Then
          i = UBound(a)
        Else
          W = 0
          L = 0
          K = 0
          j = 0
        End If
      Next i
      NewRank = Cells(r, CurrentRankCol).Value + UpDown
      If NewRank < 2 Then NewRank = 2
      If NewRank > 7 Then NewRank = 7
      Application.EnableEvents = False
      Cells(r, CurrentRankCol + 1).Resize(, 4).Value = Array(W, L, NewRank, LastReset)
      If NewRank <> OldRank Then MsgBox "New Rank for " & Range("A" & r) & " will now be moved to Current Rank and New Rank cell cleared"
      Cells(r, CurrentRankCol).Value = NewRank
      Cells(r, CurrentRankCol + 3).ClearContents
      Application.EnableEvents = True
    End If
  End If
End Sub
 
Upvote 0
I think it's starting to work! The ranks changed when they were supposed to and the counting was reset back to 0. Great!
  • I didn't merge any cells in Rows 1, 2 and 3 to indicate Years, Months and Days, but eventually that will need to be done.
  • Now I'm going throw in a wrinkle: what if the scorer makes an error in filling in Ws or Ls and has erase a few weeks of scores. Will the rank automatically go back to the previous rank, or would you have to manually change the rank? (I didn't test this out for fear of blowing everything up.)
  • Now I'm going to get greedy: Can you code it so that when a player moves up or down, the date (cell) is color-coded to indicate that this is the date that he or she moved?
IFTestBook7-Peter.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
2
3PlayerCurrent RankCurrent WinsCurrent LossesNew RankLast Reset
4First Name1234567891011121314151617181920
5Joe30015WLWWWWLLWW
6Jon30011LLLWWWWWWW
7Rich
Sheet1
 
Upvote 0
I didn't merge any cells in Rows 1, 2 and 3 to indicate Years, Months and Days, but eventually that will need to be done.
Doing that sort of thing in rows above row 4 should not be a problem


Now I'm going throw in a wrinkle: what if the scorer makes an error in filling in Ws or Ls and has erase a few weeks of scores. Will the rank automatically go back to the previous rank, or would you have to manually change the rank?
With the current code the rank will not automatically go back to what is was. After all, there is no direct record of what the previous values in the row were. Further, erasing or changing earlier data could also affect current wins & losses and also Last Reset. This is partly why I asked earlier:
** Does every player start this sheet with no current rank (or I guess that is the min rank of 2)? I am asking because this whole process (vba or formulas) may be simpler if we ignored that 'Last Reset' and just calculated all the players changes right from the start each time and published their current rank and current wins/losses.
If anything was deleted or changed anywhere before the last entry in the row, would it be feasible to effectively erase all calculations for that player and recalculate everything right from FirstDataCol after assuming that the player's initial rank was the minimum of 2 to start with?


Now I'm going to get greedy: Can you code it so that when a player moves up or down, the date (cell) is color-coded to indicate that this is the date that he or she moved?
Highlighting the date cell does not make sense to me. The date cell is in row 3 or 4 isn't it? If a date cell was highlighted, how would you know which player it related to?

I have not tried to put it into effect yet but I am thinking that when a player plays more than once per day, the best way of recording to assist the result calculation may be to simply enter both values in the cell like in H5 and K5 below. Would that be acceptable from your point of view? .. or possibly the two values could be entered with a comma or space delimiter but still in the same cell?

Also note that within the next 24 hours, I will be going away for a week or 10 days and may not have access to the forum or Excel so if I don't respond in that time you'll understand that I have not just abandoned the thread. :)

Daviboy30_1.xlsm
AGHIJKL
4First Name123456
5JoeWLWWWWWW
P32 (2)
 
Upvote 0
Highlighting the date cell does not make sense to me. The date cell is in row 3 or 4 isn't it? If a date cell was highlighted, how would you know which player it related to?
Whenever a player goes up or down you currently get message that his rank is changing. Can you also code it so that you fill the cell where the update has occurred with a color? This what I was thinking:

PlayerRankingSystem_211115.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCWCXCYCZDADBDCDDDEDFDGDHDIDJDKDLDMDNDODPDQDRDSDTDUDVDWDXDYDZEAEBECEDEEEFEGEHEIEJEKELEMENEOEPEQERESETEUEVEWEXEYEZFAFBFCFDFEFFFGFHFIFJFKFLFMFNFOFPFQFRFSFTFUFVFWFXFYFZGAGBGCGDGEGFGGGHGIGJGKGLGMGNGOGPGQGRGSGTGUGVGWGXGYGZHAHBHCHDHEHFHGHHHIHJHKHLHMHNHOHPHQHRHSHTHUHVHWHXHYHZIAIBICIDIEIFIGIHIIIJIKILIMINIOIPIQIRISITIUIVIWIXIYIZJAJBJCJDJEJFJGJHJIJJJKJLJMJNJOJPJQJRJSJTJUJVJWJXJYJZKAKBKCKDKEKFKGKHKIKJKKKLKMKNKOKPKQKRKSKTKUKVKWKXKYKZLALBLCLDLELFLGLHLILJLKLLLMLNLOLPLQLRLSLTLULVLWLXLYLZMAMBMCMDMEMFMGMHMIMJMKMLMMMNMOMPMQMRMSMTMUMVMWMXMYMZNANBNCNDNENFNGNHNINJ
12021
2JulyAugustSeptemberOctoberNovemberDecember
3Player NameCurrent RankCurrent WinsCurrent LossesNew RankLast Reset12345678910111213141516171819202122232425262728293031123456789101112131415161718192021222324252627282930311234567891011121314151617181920212223242526272829301234567891011121314151617181920212223242526272829303112345678910111213141516171819202122232425262728293012345678910111213141516171819202122232425262728293031
4123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
5Joe23231WWLWLWLWLWLWLWWWWLWLWLLLLLLWWWLL
6Jon53129WWWLWLWWWLLWLWLWLLLLWWLW
7Rich30041LLLWLWLLLLWWWWWWLWWW
Sheet1
 
Upvote 0
Whenever a player goes up or down you currently get message that his rank is changing. Can you also code it so that you fill the cell where the update has occurred with a color? This what I was thinking:
OK, I will think about that - probably should be doable.

What about my other questions?
If anything was deleted or changed anywhere before the last entry in the row, would it be feasible to effectively erase all calculations for that player and recalculate everything right from FirstDataCol after assuming that the player's initial rank was the minimum of 2 to start with?

when a player plays more than once per day, the best way of recording to assist the result calculation may be to simply enter both values in the cell like in H5 and K5 below. Would that be acceptable from your point of view? .. or possibly the two values could be entered with a comma or space delimiter but still in the same cell?
 
Upvote 0
I have not tried to put it into effect yet but I am thinking that when a player plays more than once per day, the best way of recording to assist the result calculation may be to simply enter both values in the cell like in H5 and K5 below. Would that be acceptable from your point of view? .. or possibly the two values could be entered with a comma or space delimiter but still in the same cell?
I'm not crazy about putting the W and L values in the same cell. Attached is a screen capture of what I'm envisioning now. Row 1 is for the Years, Row 2 is for the Months, Row 3 is for the Days of the Month, and Row 4 is counting the Cells. In this scenario for each player, there are two cells available each day, whether he plays two matches or not.
OK, I will think about that - probably should be doable.

What about my other questions?
If anything was deleted or changed anywhere before the last entry in the row, would it be feasible to effectively erase all calculations for that player and recalculate everything right from FirstDataCol after assuming that the player's initial rank was the minimum of 2 to start with?
Are you asking if a player's row gets messed up, for whatever reason, do we have backup? We have score sheets for each day's matches, that are filled in with pencil and paper. I've been photographing and collecting these score sheets on my iPhone. Not the best solution, but it works. I'm hoping we would not have to start from the FirstDataCol, if things got messed up. Starting from the last known "good" entry, we should be able to clear the inputs for the Current Wins and Losses, reset the Current Rank and Last Reset to the proper count, then rebuild from there. (Does that answer your question?)
 

Attachments

  • Screen Shot 2021-11-16 at 4.08.50 PM.png
    Screen Shot 2021-11-16 at 4.08.50 PM.png
    146.1 KB · Views: 9
Upvote 0
Attached is a screen capture of what I'm envisioning now.
That layout should be fine.

Are you asking if a player's row gets messed up, for whatever reason, do we have backup?
No, that is not what I am asking.

I'll try explaining again. Take your example of Joe in your post 38 screen shot (better to use XL2BB though so I can easily copy to test).
As you have shown, his last reset was in cell 31 with a current win/loss count of 3/2. Looking through Joe's row I can calculate that he moved up 1 rank at cell 19 and down 1 rank at cell 31, leaving him on a rank of 2.

What I getting at is, let's suppose we realise that the first 'L' in cell 3 (really cell I5) should have been a 'W'. Can I just say: "OK, Joe is starting again with a default rank of 2 and with that change in cell I5 Joe would have had a rank increase of 1 in cell 12, another rank increase of 1 in cell 23 and a rank decrease of 1 in cell 37 so that would leave him with a rank of 3 with last reset in cell 37 and a current win/loss count of 0/1?
 
Upvote 0
I think what you are saying is: if an error occurs, you want to manually reset his Current Rank, Current Wins and Current Losses to what they should be instead of making the computer recalculate all the Ws and Ls in order to reset his ranking to the proper rank. If this is what you mean, then yes I think I would prefer that.
But currently with the existing VBA code (I think), the counting gets messed up. They don't seem to start counting again if you erase Ws and Ls and start entering new Ws and Ls. I haven't fully tested this. The code needs to accept whatever the numbers are in the Current Rank, Current Wins and Current Losses columns and build from there. Does that make sense?

Below is the XL2BB minisheet from my spreadsheet with your latest VBA code that I used to create the screen capture in #38:

PlayerRankingSystem_211115.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCWCXCYCZDADBDCDDDEDFDGDHDIDJDKDLDMDNDODPDQDRDSDTDUDVDWDXDYDZEAEBECEDEEEFEGEHEIEJEKELEMENEOEPEQERESETEUEVEWEXEYEZFAFBFCFDFEFFFGFHFIFJFKFLFMFNFOFPFQFRFSFTFUFVFWFXFYFZGAGBGCGDGEGFGGGHGIGJGKGLGMGNGOGPGQGRGSGTGUGVGWGXGYGZHAHBHCHDHEHFHGHHHIHJHKHLHMHNHOHPHQHRHSHTHUHVHWHXHYHZIAIBICIDIEIFIGIHIIIJIKILIMINIOIPIQIRISITIUIVIWIXIYIZJAJBJCJDJEJFJGJHJIJJJKJLJMJNJOJPJQJRJSJTJUJVJWJXJYJZKAKBKCKDKEKFKGKHKIKJKKKLKMKNKOKPKQKRKSKTKUKVKWKXKYKZLALBLCLDLELFLGLHLILJLKLLLMLNLOLPLQLRLSLTLULVLWLXLYLZMAMBMCMDMEMFMGMHMIMJMKMLMMMNMOMPMQMRMSMTMUMVMWMXMYMZNANBNCNDNENFNGNHNINJ
12021
2JulyAugustSeptemberOctoberNovemberDecember
3Player NameCurrent RankCurrent WinsCurrent LossesNew RankLast Reset12345678910111213141516171819202122232425262728293031123456789101112131415161718192021222324252627282930311234567891011121314151617181920212223242526272829301234567891011121314151617181920212223242526272829303112345678910111213141516171819202122232425262728293012345678910111213141516171819202122232425262728293031
4123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
5Joe23231WWLWLWLWLWLWLWWWWLWLWLLLLLLWWWLL
6Jon53129WWWLWLWWWLLWLWLWLLLLWWLW
7Rich30041LLLWLWLLLLWWWWWWLWWW
Sheet1
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,462
Members
449,085
Latest member
ExcelError

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