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