1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Sub Test()
'Déclarations ========
Dim Cel As Range
Dim Tot As Double
Dim W As Worksheet
'MEI =================
Set W = Sheets("Feuil1") 'On attribue la feuille de nom "Feuil1" à la variable W
'Traitement ==========
For Each Cel In W.Range(W.[F1], W.Range("F" & Rows.Count).End(xlUp))
'pour chaque cellule de la plage F1 à dernière de F
If Date1 <= W.Cells(Cel.Row, "A") And W.Cells(Cel.Row, "A") <= Date2 And W.Cells(Cel.Row, "H") = Val Then
'si pour la ligne de Cel, Date1<=A<=Date2 et H=Val alors
If IsNumeric(Cel) Then Tot = Tot + Cel
'si Cel est numérique alors on additionne Cel à Tot
End If
Next Cel
'Cellule suivante
MsgBox Tot, vbOKOnly, "Total"
End Sub |