I'm fairly new to VBA and macro's, so I'm writing a post here to hopefully get some help and tips for my solution. My problem is as follows:
I need to copy an uncertain amount of cells containing data from excel-files in folders and subfolders to paste in an excel-"mother"-file:
"All files that contain data is in one folder and it's subfolders. the cells to be copied in theese files ALWAYS start at row 40, and are in cells A, B, C and D. How many rows that need to be copied however is uncertain."
What I'm looking for is code that loops through a folder and it's subfolders looking for files to get data from. I'm also thinking that inside this loop I will later write code to collect data from each individual file.
SO, what I'm looking for is: - Code to loop through a folder and subfolders to collect data from file. - Code that finds last row with data and copies all data from start to this last row. I'm thinking something like: "A40:D & UncertainRange"
All help is greatly appreciated.. afterall I'm still a VBA Noob. Have a great weekend, and may all of your problems be solved by scripting.
Good day.
Here's a command to identify the last row in an Excel sheet that has data:
To loop through your data beginning on row 40 of each file you can then use something like this:
To loop through files, use something like this:
have a look at this link: http://online-vba.de/vba_readfolder.php - change
sRootPath
with your directory without\
at the end