Function NbJourPlage(d1, d2, p1 As Range, p2 As Range)
Dim i&, x&, wf
NbJourPlage = ""
If p1.Rows.Count <> p2.Rows.Count Then Exit Function
Set wf = Application.WorksheetFunction
For i = 1 To p1.Rows.Count
x = x + wf.Max(0, wf.Min(d2, p2.Cells(i, 1)) - wf.Max(d1, p1.Cells(i, 1)) + 1)
If (p1.Cells(i, 1) = "") Or (p2.Cells(i, 1) = "") Then
NbJourPlage = ""
Exit Function
End If
Next i
NbJourPlage = x
End Function