Can anyone help me Create Excel list of files in windows folders

S

solrac1956

I had previously been able to create an Excel list of Windows Folders. I
seem to have lost that component in my personal memory. Can anyone help me.

Carlos E. Gutierrez
[email protected]
 
C

Chip Pearson

Do you mean just a list of folders? Try the following code.
You'll need a reference to the Scripting Runtime Library.

Dim FSO As Scripting.FileSystemObject
Dim Fldr As Scripting.Folder
Dim Rng As Range

Set FSO = New Scripting.FileSystemObject
Set Rng = Range("A1")
For Each Fldr In FSO.GetFolder("H:\").SubFolders
Rng.Value = Fldr.Path
Set Rng = Rng(2, 1)
Next Fldr


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



message
news:[email protected]...
 
Top