Private Sub CommandButton1_Click()
Dim ref$, date1 As Date, date2 As Date, i&, j%, k&, resu#
ref = [L2]
If Not IsDate(TextBox1) Then TextBox1 = "": TextBox1.SetFocus: Exit Sub
If Not IsDate(TextBox2) Then TextBox2 = "": TextBox2.SetFocus: Exit Sub
date1 = CLng(Application.Min(CDate(TextBox1), CDate(TextBox2)))
date2 = CLng(Application.Max(CDate(TextBox1), CDate(TextBox2)))
For i = 1 To 125 Step 31
For j = 3 To 7
If Cells(i, j) >= date1 And Cells(i, j) <= date2 Then
For k = i + 3 To i + 29
If Cells(k, j) = ref Then
If IsNumeric(Cells(k - 1, j)) Then resu = resu + CDbl(Cells(k - 1, j))
End If
Next k
End If
Next j, i
[L3] = resu
End Sub
Private Sub UserForm_Initialize()
If [L2] = "" Then [L3] = "": End 'l'UserForm ne s'ouvre pas
End Sub