1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim Ligne As Long, C As Range, Lig2 As Variant
If Not IsNumeric(Sh.Name) Then Exit Sub
If Intersect(Target, Sh.[P3:P56]) Is Nothing And _
Intersect(Target, Sh.[S3:S56]) Is Nothing Then Exit Sub
If Sh.Cells(Target.Row, "P") = "" Then Exit Sub
With Feuil1
If Target.Value <> "" Then
Lig2 = Application.Match(Format(Sh.Cells(Target.Row, "P"), "mmmm yyyy"), .[A:A], 0)
Application.EnableEvents = False
If Not IsNumeric(Lig2) Then
Ligne = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
.Cells(Ligne, 1) = Format(Target.Value, "mmmm yyyy")
.Cells(Ligne, 3) = Sh.Cells(Target.Row, "S")
Else
.Cells(Lig2, 3) = .Cells(Lig2, 3) + Sh.Cells(Target.Row, "S")
End If
Application.EnableEvents = True
End If
End With
End Sub |
Partager