how to create macro that will display the sub_subfolder
Hi Cyzax7,
Try:
'=============
Public Sub ListFolders()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Folder List"
Const sStartDir As String = "C\" '<<==== CHANGE
On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets(sName).Delete
Application.DisplayAlerts = True
Set SH = ThisWorkbook.Sheets. _
Add(after:=Sheets(Sheets.Count))
SH.Name = sName
Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder("C:\")
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr
SH.Columns("A").AutoFit
End Sub
'<<=============
---
Regards,
Norman
"cyzax7" <u22797@uwe wrote in message news:6173e848330a5@uwe...
I have a main_folder (I name it as Folder_A) which contains many subfolder
(Folder_1, Folder_2,Folder_3, ...Folder_n). where in each subfolder
contains
multiple(more than 100) number of files (.s3p format) that I want to
analyze.
I want to create a macro that will allow user to input the main_folder
directory. Then, the all the subfolder will be listed up on the mainsheet,
so
that user can choose which subfolder they want to analyze. (where user can
analyzed 1, 2, more or all the subfolder). Can someone help me on this?
I have tried so many ways, but it doesn't works.
|