"Ron Rosenfeld" wrote...
....
Function MaxWinStreak(rg As Range) As Integer
Const Wins As String = "W"
Dim c As Range
Dim TempWins As Integer
For Each c In rg
If c.Text = Wins Then
TempWins = TempWins + 1
Else
If TempWins MaxWinStreak Then MaxWinStreak = TempWins
TempWins = 0
End If
Next c
End Function
If every cell is a win, this function returns zero. If you're going to use
this approach, you have to add another
If TempWins MaxWinStreak Then MaxWinStreak = TempWins
statement after the For loop.
|