Hello everyone,
I'm sure my problem is quite simple, and I've found many threads requesting similar things, but somehow none of them seem to work for me.
Here is what I want to do: loop through a folder, grabbing all the xls files with a specific string contained in them, and then put them all end to end inside of a master excel file.
As of right now, I'm ignoring the "specific string" bit in the hopes of just getting something working. All my files have all their data on Sheet1, and all have a header row in row 1 and data starting in row 2. Files of the same type have identical header rows, and can have missing values in many columns (some are completely empty).
My attempt so far:
This seems to copy everything on top of the previously copied files, so the contents of the last file is the only thing present in the finished product. I'm also not sure how to get the header row across.
Out of all the different sheet categories, none have greater breadth than CT, hence I used that variable. The number of observations is variable though.
EDIT:
I thought that the line
Was the problem, so I tried switching it with
but that just gives me the headers. The very first column can be completely blank, so I guess that is the issue.
I'm trying to get a handle on how range really works because I obviously don't understand it, but I haven't really found a good resource. The help page isn't that helpful. Any suggestions of somewhere to read up?
EDIT2:
I ran the following code:
where column B is filled for every row in this specific worksheet category. Now I get all the data, however it starts on the second row and a header row gets pasted for each import.
Bookmarks