Dans mon fichier « BASE DONNEES », une macro permet d’exporter la feuille « Base », la plage de cellules A2 à G235 dans le fichier « FRAIS BANCAIRES » à la dernière cellule vide.
Il y a cependant un message d’erreur qui indique : « Erreur de compilation : variable non définie ». Je ne vois pas pourquoi.
Sub exporter()
Dim lgn As Long
Sheets("Base").Select
Range("A2:G" & Range("A" & Rows.Count).End(xlUp).Row).Copy
On Error GoTo DossierFermé
With Workbooks("FRAIS BANCAIRES.xlsx").Sheets("BD")
lgn = .Range("A" & Rows.Count).End(xlUp)(2).Row
.Range("A" & lgn).PasteSpecial xlPasteAll
End With
Application.CutCopyMode = False
MsgBox "Travail terminé"
Exit Sub
DossierFermé:
MsgBox "Merci d'ouvrir le fichier ''FRAIS BANCAIRES.xlsx'' ", 16
End Sub