Sub test()
With Application.FileSearch
ref = Range("y18")
.NewSearch
.LookIn = "\\192.168.5.5\Public\共享檔案\2018 CS\" '<---你的路徑
.SearchSubFolders = True
.Filename = "*.xls" '<---你要找的檔案類型
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
For I = 1 To .FoundFiles.Count
On Error Resume Next
Cells(I, 3) = .FoundFiles(I)
Next I
Else
MsgBox "Folder " & sFolder & " contains no required files"
End If
End With
End Sub