I am using the following code
Sub Ck()
Dim strStartPath As String
strStartPath = "d:\workpack\rr a"
ListFolder strStartPath
End Sub
Sub ListFolder(sFol derPath As String)
Dim FS As New FileSystemObjec t
Dim FSfolder As Folder
Dim subfolder As Folder
Dim i As Integer
Set FSfolder = FS.GetFolder(sF olderPath)
For Each subfolder In FSfolder.SubFol ders
DoEvents
i = i + 1
'added this line
Cells(i, 1) = subfolder
'commented out this one
'Debug.Print subfolder
Next subfolder
Set FSfolder = Nothing
End Sub
to return the subfolder names into cells in excel, problem is this also returns the path (ie D:\workpack\rra \example1), I only want the subfolder name, how can I do this?
Sub Ck()
Dim strStartPath As String
strStartPath = "d:\workpack\rr a"
ListFolder strStartPath
End Sub
Sub ListFolder(sFol derPath As String)
Dim FS As New FileSystemObjec t
Dim FSfolder As Folder
Dim subfolder As Folder
Dim i As Integer
Set FSfolder = FS.GetFolder(sF olderPath)
For Each subfolder In FSfolder.SubFol ders
DoEvents
i = i + 1
'added this line
Cells(i, 1) = subfolder
'commented out this one
'Debug.Print subfolder
Next subfolder
Set FSfolder = Nothing
End Sub
to return the subfolder names into cells in excel, problem is this also returns the path (ie D:\workpack\rra \example1), I only want the subfolder name, how can I do this?
Comment