I can explain this part of the thread I mentioned earlier:
http://www.mrexcel.com/forum/showpost.php?p=1951156&postcount=3
What this does is it takes the directory you specify (something "C:\" or "C:\Program Files\", etc) and loops through every file in that directory.
As it loops through this code, it adds each file it finds to an object known as a collection. What a collection is is exactly what it sounds like: a collection of "things". In this case, we're adding file names to the collection. Every time we add one, the collection grows bigger (naturally!).
Okay, so that's that part. I commented the code in the thread at the link above pretty heavily, and hopefully in plain enough english to be fairly easily understood.
Now, the piece not in that thread ('cuz it wasn't applicable) was the piece where you write it to a worksheet. What makes the collection great is that it's very easy to work with (easier I find than an array).
So, after the first For/Next loop in the code in the above thread, you want to do something like this to get it into a worksheet:
Code:
' This is the part where we write the file names
' to a worksheet.
For i = 1 To coll.Count
' We're choosing this workbook and the very generic Sheet1
' to write our file names out to. Presuming you want to start
' at row 2 (leaving row 1 for a header), then we simply
' fill in the cells(row,col) with the items in the collection
' by iterating through it with a For/Next loop.
ThisWorkbook.Sheets("Sheet1").Cells(i+1, 1).Value = coll(i)
Next i
Bare in mind, you can change the target workbook, worksheet, and range where you want these file names to go by changing the elements of this line:
Code:
ThisWorkbook.Sheets("Sheet1").Cells(i+1, 1).Value = coll(i)
In addition, if you want to get "fancy" you can filter for the type of files you want by applying some kind of If statement or Select/Case to the For/Next loop that runs through the directory. But maybe that's getting ahead of ourselves?