Folder listing

E

Esradekan

I want to get a folder listing (from a specific folder) that shows sub
folders in the next column (under the parent folder). How do I do
that does anyone know?

TIA >(*-*)<

Esra
 
H

Héctor Miguel

hi, Esra !
I want to get a folder listing (from a specific folder) that shows sub folders in the next column (under the parent folder)...

does a vba-macro serves well ?

Sub List_Subfolders()
Dim StartPath As String, FName As String, n As Integer
StartPath = Range("a1").Text
If Right(StartPath, 1) <> "\" Then StartPath = StartPath & "\"
FName = Dir(StartPath & "*", vbDirectory)
Do While FName <> ""
If (GetAttr(StartPath & FName) And vbDirectory) = vbDirectory Then _
If FName <> "." And FName <> ".." Then _
Range("b1").Offset(n) = FName: n = n + 1
FName = Dir()
Loop
End Sub

hth,
hector.
 
E

Esradekan

hi, Esra !


does a vba-macro serves well ?

Sub List_Subfolders()
  Dim StartPath As String, FName As String, n As Integer
  StartPath = Range("a1").Text
  If Right(StartPath, 1) <> "\" Then StartPath = StartPath & "\"
  FName = Dir(StartPath & "*", vbDirectory)
  Do While FName <> ""
    If (GetAttr(StartPath & FName) And vbDirectory) = vbDirectory Then _
      If FName <> "." And FName <> ".." Then _
        Range("b1").Offset(n) = FName: n = n + 1
    FName = Dir()
  Loop
End Sub

hth,
hector.

Hi Hector,

Thanks for the reply, but I'm not sure how to use this (adapt it for
my purposes). Where do I change this so I can insert the folder name
that will be my 'parent' folder?

Am I having a blonde moment?

Esra

TIA
 
M

minyeh

Hi Hector,

Thanks for the reply, but I'm not sure how to use this (adapt it for
my purposes).  Where do I change this so I can insert the folder name
that will be my 'parent' folder?

Am I having a blonde moment?

Esra

TIA- Hide quoted text -

- Show quoted text -

To answer Esra question,

1. press [Alt]+[F11] to open the VB Editor.
2. Choose Insert --> Module and copy the code above given by Hector
and paste it into the module.
3. Close the VB Editor.
4. in cell A1, key in ur directory for your parent folder i.e. D:
\Parent\
5. run the macro (you could apply a short-cut key or put a button or
shape such as the text box from the drawing toolbar on the sheet and
attach the macro to it), and the folder listing will appear in column
B


To Hector,

Have a similar question, how can i get a file listing from a specific
folder including its subfolders?
for example, my parent folder is "Customer List"
under that Folder, i have several sub folders named like "A-F", "G-L",
"M-R", "S-Z",
and under each folders is the sales reports [.xls] or [.xlsx] for each
customers, named by their customer ID and the date of last modified.
can i get a master listing of these files (excluding the folders)
including the filetype? (either in one column or two column is fine)
Thanks a lot, i've been trying this for a while and it makes me
headache.

Min Yeh
 
E

Esradekan

On Mar 30, 8:12 pm, "H ctor Miguel" <[email protected]>
wrote:
Hi Hector,
Thanks for the reply, but I'm not sure how to use this (adapt it for
my purposes).  Where do I change this so I can insert the folder name
that will be my 'parent' folder?
Am I having a blonde moment?

TIA- Hide quoted text -
- Show quoted text -

To answer Esra question,

1. press [Alt]+[F11] to open the VB Editor.
2. Choose Insert --> Module and copy the code above given by Hector
and paste it into the module.
3. Close the VB Editor.
4. in cell A1, key in ur directory for your parent folder i.e. D:
\Parent\
5. run the macro (you could apply a short-cut key or put a button or
shape such as the text box from the drawing toolbar on the sheet and
attach the macro to it), and the folder listing will appear in column
B

To Hector,

Have a similar question, how can i get a file listing from a specific
folder including its subfolders?
for example, my parent folder is "Customer List"
under that Folder, i have several sub folders named like "A-F", "G-L",
"M-R", "S-Z",
and under each folders is the sales reports [.xls] or [.xlsx] for each
customers, named by their customer ID and the date of last modified.
can i get a master listing of these files (excluding the folders)
including the filetype? (either in one column or two column is fine)
Thanks a lot, i've been trying this for a while and it makes me
headache.

Min Yeh- Hide quoted text -

- Show quoted text -

Isnt part of that what I was wanting?

Thank you Hector, I appreciate your efforts. I just found an add-in
at Chip Pearsons website (www.cpearson.com I think from memory) and
works a treat to do just what you want here. Check it out.

Esra.
 
H

Héctor Miguel

hi, minyeh !
Have a similar question, how can i get a file listing from a specific folder including its subfolders?
for example, my parent folder is "Customer List" under that Folder, i have several sub folders named like "A-F", "G-L", "M-R", "S-Z",
and under each folders is the sales reports [.xls] or [.xlsx] for each customers, named by their customer ID and the date of last modified.
can i get a master listing of these files (excluding the folders) including the filetype?
(either in one column or two column is fine) ...

as Esra comments, Chip Pearson as in his web-site articles related to this listing folders-files (i.e.)
http://www.cpearson.com/excel/FolderTree.aspx

and downloadable examples as:
http://www.cpearson.com/Zips/DirTreeXLS.zip
http://www.cpearson.com/Zips/DirTreeSetup;.zip

hth,
hector.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

file names 4
Comment in specific place 3
Sports summary sheet - think I put this in wrong place originally 1
cell vlue based on cell back colour 6
Cell format 3
Blinking Text 42
Month formula 9
Rounding 5

Top