Hi,
Im trying to get some data from multiple excel files to one file using the following code.
The macro now copies information from a excel file (G10:T10) and pasts it in a cell than opens the next excel file, copies the information and pastes it in the same cell.
My problem is that i want the copied data not to be overwritten but to be pasted under each other, so it will result in a list of information.
I hope someone could help me with this!
Sub ConsolidateData()
Dim FileSystem As Object, myFolder As Object
Dim myFiles As Object, myFile As Object
Dim wkb, Col As Integer, result
Set FileSystem = CreateObject("Scripting.FileSystemObject")
Set myFolder = FileSystem.getfolder(CurDir)
Set myFiles = myFolder.Files
For Each myFile In myFiles
Col = ThisWorkbook.Sheets(1).UsedRange.Columns.Count
Workbooks.Open (myFile)
ActiveWorkbook.Sheets(1).Range("G10:T10").Copy
ActiveSheet.Paste Destination:=ThisWorkbook.Sheets(1).Cells(1, Col) '= ActiveWorkbook.Sheets(1).Range("G10:T10")
Workbooks.Open(myFile).Close False
Next myFile
End Sub
Bookmarks