tinkerv102
New Member
- Joined
- Aug 14, 2018
- Messages
- 8
Hello,
I am trying to code macro to consolidate all workbooks in a file on my computer. My macro seems to work but is not pasting in data from the other files into my master (zbook1). Can anyone assist?
Sub LoopThroughDirectory()
Dim MyFile As String
Dim erow
Dim Filepath As String
Filepath = "C:\Users\n0234704\Desktop\LOGS"
MyFile = Dir(Filepath)
Do While Len(MyFile) > 0
If MyFile = "zbook1.xlsx" Then
Exit Sub
End If
Workbooks.Open (Filepath & MyFile)
Range("A10:O10").Copy
ActiveWorkbook.Close
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range(Cells(erow, 1), Cells(erow, 15))
MyFile = Dir
Loop
End Sub
I am trying to code macro to consolidate all workbooks in a file on my computer. My macro seems to work but is not pasting in data from the other files into my master (zbook1). Can anyone assist?
Sub LoopThroughDirectory()
Dim MyFile As String
Dim erow
Dim Filepath As String
Filepath = "C:\Users\n0234704\Desktop\LOGS"
MyFile = Dir(Filepath)
Do While Len(MyFile) > 0
If MyFile = "zbook1.xlsx" Then
Exit Sub
End If
Workbooks.Open (Filepath & MyFile)
Range("A10:O10").Copy
ActiveWorkbook.Close
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range(Cells(erow, 1), Cells(erow, 15))
MyFile = Dir
Loop
End Sub