1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Sub Macro1()
Dim i As Integer
Dim NbFiles As Integer
Dim LastLig As Long
Dim LastLig_TWB As Long
Dim LastCol As Integer
Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = "S:\POUET"
.SearchSubFolders = False
.Filename = "TAGADA" & "*.xls"
.Execute
For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i)
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
LastLig = Cells(Rows.Count, 1).End(xlUp).Row
LastLig_TWB = ThisWorkbook.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
Sheets(1).Range(Cells(2, 1), Cells(LastLig, LastCol)).Select
Selection.Copy
ThisWorkbook.Sheets(1).Cells(1 + LastLig_TWB, 1).Paste
'ThisWorkbook.Sheets(1).Range(Cells(1 + LastLig_TWB, 1), Cells(LastLig_TWB + LastLig, LastCol)) = Sheets(1).Range(Cells(2, 1), Cells(LastLig, LastCol)).Value
'LastLig_TWB = ThisWorkbook.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
Workbooks(Dir(.FoundFiles(i))).Close
Next i
End With
Application.ScreenUpdating = True
End Sub |
Partager