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 28 29 30 31 32
| Function BARYCENTRE(Cel As Range, Prod As Boolean) As Double
Application.Volatile
Application.ScreenUpdating = False
Dim Lig As Integer
Dim Col As Integer
Dim i As Integer
Dim Total As Double
'Initialisation des données
Lig = Cel.Row
Col = Cel.Column
Total = 0
i = Lig + 1 'On démarre à la ligne en dessous
'Boucle par ligne jusqu'à une cellule vide
Do Until Cells(i, Col) = ""
If Prod = False Then
Total = Total + Cells(i, Col)
Else
Total = Total + Cells(i, Col) * Cells(i, Col - 1)
End If
i = i + 1
Loop
If Prod = False Then
BARYCENTRE = Total
Else
BARYCENTRE = Total / Cells(Lig, Col - 1)
End If
Application.ScreenUpdating = True
End Function |
Partager