Here's some code I have found, with some customizing added
Sub GetInvoiceData()
Dim i As Integer
Dim wbResults As Workbook
Dim wbCodeBook As Workbook
Range("A2:F400").ClearContents 'delete sheet to suite
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
On Error Resume Next
Set wbCodeBook = ThisWorkbook
With Application.FileSearch
.NewSearch
'Change path to suit
.LookIn = "C:\Invoices\"
.FileType = msoFileTypeExcelWorkbooks
If .Execute > 0 Then 'Workbooks in folder
For i = 1 To .FoundFiles.Count 'Loop through all
'Open Workbook x and Set a Workbook variable to it
Set wbResults = Workbooks.Open(.FoundFiles(i))
Workbooks("InvoiceTest").Sheets("Sheet1").Range("A3000").End(xlUp).Offset(1, 0) = Range("M3")
Workbooks("InvoiceTest").Sheets("Sheet1").Range("B3000").End(xlUp).Offset(1, 0) = Range("D13")
Workbooks("InvoiceTest").Sheets("Sheet1").Range("C3000").End(xlUp).Offset(1, 0) = Range("M13")
Workbooks("InvoiceTest").Sheets("Sheet1").Range("D3000").End(xlUp).Offset(1, 0) = Range("E17")
'Sheets("Invoice").Range ("M3,D13:H13,E17,M13")
ActiveWorkbook.Close savechanges:=False
Next i
End If
End With
On Error GoTo 0
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub
This code originated from this site
This code is available from many sites.
Bookmarks