Macro isn't consolidating data

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
 
Hi Yongle,

I am going to give this a try and see if it works. I have been without a computer as I was trying to migrate to a new laptop. Hoping this does the trick. Thank you so much for helping me out with this. I really appreciate it!
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Reran the new coding..Still didn't pull the data in... Unsure what to do at this point feels like the never ending troubleshooting problem. It looks like the macro does fill through all the files as I see the updates occuring to them individually but they do not consolidate into the zbook.
 
Upvote 0
VBA is not or the faint hearted :)
It is entirely your choice. If you have not got the energy to pursue then say so.
feels like the the never ending troubleshooting problem
Sounds like a bail out to me. I have nothing to gain from it but am quite prepared to help you and we will get there. Let me know
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top