Sub CalculeTotal()
'
Dim LigneTotal As Long
Dim Colonne As Long
Dim i As Integer
'
' On détermine la dernière ligne en fonction du
' nombre d'ingrédients présents en ligne B et
' on la sauvegarde dans la variable LigneTotal
LigneTotal = Range("B65536").End(xlUp).Row
' Si la ligne trouvée ne contient pas "Total"
' en colonne B, on incrémente LigneTotal et
' on inscrit la valeur "Total" dans cette
' ligne calculée
If Cells(LigneTotal, "B") <> "Total" Then
LigneTotal = LigneTotal + 1
Cells(LigneTotal, "B") = "Total"
End If
' Enfin, avec la ligne sur laquelle est écrit
' "Total" en colonne B, on scanne toutes les
' colonnes de C à F, i.e. 3 à 6 (celles qui
' ont pour titre "A", "B", "C" et "D" et on
' fait le total des lignes 4 à (LigneTotal - 1)
For i = 3 To 6
With Application.WorksheetFunction
Cells(LigneTotal, i) = .Sum(Range(Cells(4, i), Cells(LigneTotal - 1, i)))
End With
Next i
End Sub