Bonjour à tous...🤝 J'ai un problème pour modifier un code pour calculer la somme d'un certain domaine. J'ai réussi à en créer une partie, mais je n'ai pas pu continuer. Pouvez-vous m'aider s'il vous plaît. C'est le code que j'utilise pour calculer certains chiffres sous condition.. Je voudrais, après avoir terminé, obtenir la somme des enceintes en un seul chiffre, comme indiqué dans le fichier joint.
Sub SUM()
Dim LastRow As Long, i As Long, X As Long, MH As Long
Application.DisplayAlerts = False
X = 1
With ThisWorkbook.Worksheets("FEUIL1")
LastRow = .Cells(.Rows.Count, "C").End(xlUp).Row + 1
For i = 1 To LastRow
If .Range("b" & i).Value = "toutal-A" Or .Range("b" & i).Value = "toutal-B" Then
MH = i - 1
.Range("C" & i).Value = Application.SUM(.Range(.Cells(X, 3), .Cells(MH, 3)))
.Range("D" & i).Value = Application.SUM(.Range(.Cells(X, 4), .Cells(MH, 4)))
.Range("E" & i).Value = Application.SUM(.Range(.Cells(X, 5), .Cells(MH, 5)))
X = i + 1
Application.DisplayAlerts = True
End If
Next i
End With
End Sub