Option Explicit
Sub DemLWA_WP()
Dim Rng As Range, Clls As Range, sRng As Range, fRng As Range
Dim Dem As Byte, Max_ As Byte, MyColor As Byte, So1 As Byte
Dim Jj As Long, lRow As Long, Timer_ As Double
Application.ScreenUpdating = False
lRow = Cells.Find(What:="*", After:=Cells(1, 1), SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
MyColor = [A5].Interior.ColorIndex + 1
Columns("A:A").Interior.ColorIndex = 0: Timer_ = Timer()
For Jj = 6 To lRow
Set fRng = Rows(Jj).Find("W", , xlFormulas, xlPart)
If Not fRng Is Nothing Then
Set Rng = Range(fRng.Offset(, -1), Cells(Jj, 255).End(xlToLeft))
With Application.WorksheetFunction
So1 = .CountIf(Rng, "*" & "W" & "?")
End With
If So1 = 1 Then
Max_ = 1
ElseIf So1 = 2 Then
Set sRng = Rng.Find("W", , , xlPart)
If InStr(sRng.Offset(, 1).Value, "W") = 0 Then Max_ = 1 Else Max_ = 2
ElseIf So1 > 2 Then
Dem = 0
For Each Clls In Rng
With Clls
If .Value <> "" And InStr(.Value, "W") > 0 Then
Dem = Dem + 1: If Max_ < Dem Then Max_ = Dem
Cells(Jj, 1).Interior.ColorIndex = 34 + Jj Mod 7
ElseIf .Value = "" Or InStr(.Value, "W") = 0 Then
If Max_ < Dem Then Max_ = Dem
Dem = 0
End If
End With
Next Clls
End If
If Max_ > 0 Then
Cells(Jj, 1).Value = Max_: Max_ = 0
End If
End If
Next Jj
[A2] = Timer() - Timer_
[A5].Interior.ColorIndex = IIf(MyColor > 41, 34, MyColor)
End Sub