WIN-DRAW-LOSS? Win Streak Formula

Fraserj

Board Regular
Joined
Nov 29, 2015
Messages
63
A
B
C
D
E
F
1
Home Team
Home Goals
-
Away Goals
Away Team
W-D-L<strike></strike>
2
NMFC
2
-
1
Chelsea
3
NMFC
3
-
1
Norwich
4
Liverpool
3
-
2
NMFC
5
NMFC
1
-
0
Arsenal
6
Manchester United
2
-
1
NMFC

<tbody>
</tbody>

Hello, My table currently looks like the one above, I need a few formulas which hopefully I will learn from aswell as just putting in my spreadsheet.
First of All, I need "Column F" to determine whether NMFC have a Win, Draw or Loss (W-D-L)


Secondly, Possibly in "Cell G2" to calculate the Win Streak of which they are on now (most recent) plus highest number of Wins in a row NMFC have had in their History in "Cell G3"

And Finally In "Cell G4" is it possible to Create a Form sheet, looking up Criteria in the W-D-L Column, to give a result of the last 5 games, so from the table above it would appear as "WWLWL" with W being green, D being Orange and L being Red. (I don't know if that would be easier to make the W-D-L column results appearing in those colours, I could do that Column from conditional formatting if that isn't the easier option, "I" just don't know how to do it when they're all together

Thank You in advance
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
In a Normal Module (Macro) add:

Code:
Function countlast() As Integery = 0
For x = Cells(Rows.Count, "G").End(xlUp).Row To 1 Step -1
    If Cells(x, 7) = "W" Then
       y = y + 1
    Else: x = 0
    End If
Next x
countlast = y
End Function


In Worksheet_Change Vba add:

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

    Call countlast
End Sub

In G2 :

Code:
=countlast()


In my worksheet Column A is Dates...

I've put the dates of the results in Column A... I've clicked on the Module and it's telling me "Function countlast() As Integery = 0" is wrong, coming up red...Is there something I need to do, sorry i'm a beginner basically when it comes to Macros, I was hoping to do it without so it would work on a Mobile device, but if it's the only way i'll use this.

Just so you know what i'm doing and what steps i'm doing wrong... I right click on tab...View Code... "Clicked on MODULE1"... Pasted that first code into it.... clicked on the relevant worksheet VBA Projects... Pasted 2nd macro you have created.... Then I have put =countlast() in as a formula into G2.

Is that right, and if I was to drag that to another worksheet, would it work, or would I have to type something into a macro for that to be done?

Sorry and Thank You
 
Upvote 0
"Function countlast() As Integery = 0" is wrong, coming up red...

Code:
Function countlast() As Integery 
y = 0
For x = Cells(Rows.Count, "G").End(xlUp).Row To 1 Step -1
    If Cells(x, 7) = "W" Then
       y = y + 1
    Else: x = 0
    End If
Next x
countlast = y
End Function
 
Upvote 0
Still not working, I don't know what I'm doing wrong D:

Change Worksheet_Change to this:

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)    
    If Target.Address = Range("A:G").Address Then
    Call countlast
    End If
End Sub
 
Upvote 0
2ykx1d5.jpg
[/IMG]
2sbra4j.jpg
[/IMG]
~
15dri3c.jpg
[/IMG

Still not working
 
Upvote 0
Ok Finished product:



In G2:



In I2: This is currently not automatic, you must select I2 and hit enter so it refreashes.



In I3:




Hope this works for you.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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