1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Function SommeValeursColonne8SiColonne2ContientUnNombre()
Dim ligne As Integer
Dim Sum As Long
Sum = 0
ligne = Application.Caller.Row + 1 'les nombres comptées démarrent sous la ligne ou la formule est appelée
'Résultat affiché en gras
Cells(ligne, 8).Font.Bold = True
'Sommer toutes les valeurs de la colonne 8 ayant un nombre en colonne 2
Do While Cells(ligne, 2).Value <> "" 'les nombre sont en colonne 2
If IsNumeric(Cells(ligne, 8).Value) = True Then 'valeurs à sommer en colonne 8
Sum = Sum + Cells(ligne, 8).Value
MsgBox Cells(ligne, 8).Font.Bold
End If
ligne = ligne + 1
Loop
'Retourner la somme dans la cellule
SommeValeursFichesMOE = Sum
End Function |
Partager