ThrottleWorks
Excel Ninja
Hi,
I am using below mentioned code to get filenames from a folder.
However, I am facing a bug at ‘With Application.FileSearch’ line.
The code is copied from ‘https://www.automateexcel.com/vba/list-all-files/’.
Can anyone please help me in this.
I am using below mentioned code to get filenames from a folder.
However, I am facing a bug at ‘With Application.FileSearch’ line.
The code is copied from ‘https://www.automateexcel.com/vba/list-all-files/’.
Can anyone please help me in this.
Code:
'https://www.automateexcel.com/vba/list-all-files/
Sub List_All_The_Files_Within_Path()
Dim Row_No As Integer
Dim No_Of_Files As Integer
Dim kk25 As Integer
Dim File_Path As String
File_Path = "C:\Users\a\Desktop\b"
Row_No = 1
'Lists all the files in the current directory
With Application.FileSearch
.NewSearch
.LookIn = File_Path
.Filename = "*.*"
.SearchSubFolders = False
.Execute
No_Of_Files = .FoundFiles.Count
For kk25 = 1 To No_Of_Files
Worksheets("Sheet1").Cells(kk25 + 5, 15).Value = .FoundFiles(kk25)
Next kk25
End With
End Sub