Copy data from workbooks in a folder to one master workbook

jayn309

New Member
Joined
Feb 17, 2023
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Untitled.png

Hi. I have data in multiple workbooks in a folder with the same template and I need to extract those circled data into one master workbook as below
1676679511818.png


I have a code to loop thru all the workbooks in the folder but I do not know how to do the data copying/extracting. Thank you for any help!.

VBA Code:
Sub LoopAllFilesInAFolder()

'Loop through all files in a folder
Dim fileName As Variant
fileName = Dir("C:\Users\Student\Documents\6004*")

While fileName <> ""
    
    'Insert the actions to be performed on each file
    
Wend

End Sub
 
Check to make sure that all the file names start with "600" and have an "xlsx" extension.
I tested with some directories directly to some subfolders, it scanned through all of them and copied the data. But if I go back to the folder of those subfolders, it only scan 1 random subfolder. I check all the files and their names start with "600" with xlsx extension. Would the number of files be the issue if there are too many of them?
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Would the number of files be the issue if there are too many of them?
That should not be a problem. Try replacing this line of code:
VBA Code:
If File.Name Like "600*.xlsx"
with this one:
VBA Code:
If File.Name Like "*600*.xlsx"
 
Upvote 0
That should not be a problem. Try replacing this line of code:
VBA Code:
If File.Name Like "600*.xlsx"
with this one:
VBA Code:
If File.Name Like "*600*.xlsx"
Hi. Some files got opened and closed really quick during the process but the issue still remains.
 
Upvote 0
Please upload 2 or three of the files that are not being opened and post the links here.
 
Upvote 0
Please upload 2 or three of the files that are not being opened and post the links here.
Hi! I will just go with your previous to scan each level of folders instead since it's too mush to go through all levels and files! Thank you so much for your help.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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