Re : Faire des Sommes en Vba dans une BDD avec données saisie avec Usf
Bonjour,
Une piste avec le code évènementiel ci-dessous
A copier dans Feuil1(INTERVENTIONS)
**************
Private Sub Worksheet_Change(ByVal Target As Range)
Dim var
Dim var2
Dim initial#
Dim totalCredit#
Dim totalDebit#
Dim tempo
Dim R As Range
Dim i&
Dim cpt&
var = ActiveSheet.UsedRange
If IsNumeric(var(1, 12)) Then initial# = var(1, 12)
Set R = Range(Cells(3, 9), Cells(UBound(var, 1), 9))
var2 = R
For i& = 3 To UBound(var, 1)
cpt& = cpt& + 1
If IsNumeric(var(i&, 7)) Then totalDebit# = totalDebit# + var(i&, 7)
If IsNumeric(var(i&, 8)) Then totalCredit# = totalCredit# + var(i&, 8)
tempo = totalCredit# - totalDebit#
If IsNumeric(tempo) Then
tempo = CDbl(tempo) + initial#
var2(cpt&, 1) = tempo
tempo = 0
End If
Next i&
Application.EnableEvents = False
R = var2
R.NumberFormat = "#.##00 €"
[L2] = totalCredit#
[L3] = totalDebit#
Range("L2:L3").NumberFormat = "#.##00 €"
Application.EnableEvents = True
End Sub
**************
Cordialement.
PMO
Patrick Morange