XL 2016 excel 2016 VBA

rebatte

XLDnaute Nouveau
BONSOIR;

j'ai réalisé un code pour extraire des donnés depuis une base de donnés selon intervalle de date mais le code en question n'a pas fonctionné ?
ci joint le fichier excel
merci pour tous les membres.

voila le code

VB:
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
 

Pièces jointes

  • 07 01 - Copie.xlsm
    220 KB · Affichages: 3

sylvanu

XLDnaute Barbatruc
Supporter XLD
Bonsoir Rebatte,
1- Ce n'est pas "With Sheets("base_gasoil")" mais "With Sheets("base_gazoil")"
2- Ce n'est pas "DL = .[A500000].End(xlUp).Row" mais "DL = .[B500000].End(xlUp).Row"
Avec ces deux modifs, ça a l'air de marcher.
 

Pièces jointes

  • 07 01 - Copie.xlsm
    194.1 KB · Affichages: 1

Statistiques des forums

Discussions
312 207
Messages
2 086 233
Membres
103 161
dernier inscrit
Rogombe bryan