How to loop through workbooks in a folder and import data to a master workbook VBA?

Bobstar

New Member
Joined
Oct 7, 2020
Messages
20
Office Version
  1. 2019
Platform
  1. Windows
Hi all

I am desperately looking for help to automate my work. I am looking for help with a code that can do the following:
  1. Open a folder
  2. Loop through multiple workbooks in that folder
  3. For each workbook in that folder, import data contained in the "Summary" sheet to thisWorkbook (workbook containing the code) in sheet named "Data"
PS: The columns in the Summary worksheet are fixed (A:G) but the rows are variable depending on the workbook.

Your help is very much appreciated.

Thanks
 
You are very well come
And thank you for the feedback
Be happy
Hi. Thanks for your earlier help.
I am wondering whether your code could be expanded to do the following:
  1. The workbooks in the folder are labelled by dates for example “17/10/2020 workbook 1.”I would like vba to get the newest workbook based on date.
  2. Copy the data from the newest workbook in a separate sheet. Lets call it “newest data”.
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
FTI “17/10/2020 workbook 1.”
File name can not contain some character , "/" one of them
 
Upvote 0
FTI “17/10/2020 workbook 1.”
File name can not contain some character , "/" one of them
You are right. The file names are in this format “17102020 Workbook1”. I could rename them in a manner vba can identify which is the newest date. Any ideas?
 
Upvote 0
this Link might help
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,174
Members
448,870
Latest member
max_pedreira

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