Option Explicit
Function compte(Optional lig As Long = 2)
Application.Volatile 'selon le besoin…
If lig = 0 Then lig = 2
Dim c As Range, t As Integer, Cpte As Integer
For t = 1 To Sheets.Count
Set c = Sheets(t).Range("A" & lig)
Do While Sheets(t).Cells(1, c.Column) <> ""
If c = "RF" Or c = "" Or c = "P1" Then
Cpte = Cpte + 1
Else
'If compte < Cpte Then compte = Cpte
Cpte = 0
End If
If compte < Cpte Then compte = Cpte
Set c = c(1, 2)
Loop
Next
End Function