Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Fin: If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, [D9]) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
DL = [A500000].End(xlUp).Row
If DL > 11 Then Range("B12:F" & DL).ClearContents
With Sheets("base_gasoil")
Ligne = 12
DL = .[A500000].End(xlUp).Row
For L = 10 To DL
If ((.Cells(L, "B") >= Range("D7")) And (.Cells(L, "B") <= Range("D9"))) Then
CopieLigne L, Ligne
Ligne = Ligne + 1
End If
Next L
End With
End If
Fin:
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Sub CopieLigne(L, Ligne)
Application.ScreenUpdating = False
With Sheets("base_gasoil")
Cells(Ligne, 2) = .Cells(L, 2) 'DATE
Cells(Ligne, 3) = .Cells(L, 3) 'N° DE PARC
Cells(Ligne, 4) = .Cells(L, 4) 'EQUIPEMENT
Cells(Ligne, 5) = .Cells(L, 5) 'NOM DE L'AGENT
Cells(Ligne, 6) = .Cells(L, 7) 'CONSOMMATIONS
End With
End Sub