XL 2010 autofilter vers un autre fichier excel

yahya belbachir

XLDnaute Occasionnel
Bonjour
qui peut me rectifier ce code
ce code a pour objet de faire filtrer les données d'un fichier excel vers un autre , le code est ceci:

Dim xlBook As Workbook '(fichier source)
Dim xlBooko As Workbook '(fichier de chercher)
Dim xlSheet As Worksheet
Dim fso As Object
Dim MaPlage As Range

Const strPath As String = "C:\Users\HP\Desktop\2019\"
Const strName As String = "BD.xlsm"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(strPath & strName) Then
On Error Resume Next
Set xlBook = Workbooks(strName) 'see if the book is open
If xlBook Is Nothing Then 'if not open it
With xlBook
Set xlBook = Workbooks.Open(strPath & strName)
Set xlSheet = xlBook.Sheets(1)


Set MaPlage = xlBook.xlSheet.Range("B1:L" & .Range("B" & Rows.Count).End(xlUp).Row)
End With
Set xlBooko = ThisWorkbook
With xlBooko.Worksheets("filtre")
MaPlage.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=.Range("E2:E3"), _
CopyToRange:=.Range("B5:L5"), Unique:=False
End With
End If
End If
xlBook.Save
xlBook.Close


merci
 

Discussions similaires

Réponses
1
Affichages
177
Réponses
2
Affichages
271