Hello I am trying to get specific files by extension from multiple folders and their subfolders and I am having trouble with this task. WHat I have so far is:
Sub ListFiles()
'Declare variables
Dim i As Long
Dim fileName As Variant
fileName = Dir("J:\BREAKDOWNS\*.PDF")
i = 2
While fileName <> ""
Cells(i, 1).Value = Left(fileName, Len(fileName) - 4)
i = i + 1
fileName = Dir
Wend
End Sub
Could someone, please, help?
P.S.
What I need and what I got so far is
folder = "J:\BREAKDOWNS\*.PDF"
sn = Split(CreateObject("wscript.shell").exec("cmd /c Dir """ & folder & ibox & """ /s /a /b").StdOut.ReadAll, vbCrLf)
Sheets(1).Cells(2, 1).Resize(UBound(sn) + 1) = Application.Transpose(sn)
But it returns teh full address, where I need just teh filename without extension even.