Hello, I have following code to search for files from given path. My purpose is to get the list of the "file names" from specified folder (i.e. Mar_2014 or Jan_204) on blank worksheet when I click the command button that has a macro with the path where all files have been stored by month. The following script giving me error and due to my inexperience I am totally blank what need to be done next to make this work. I would appriciate any help, Thank you so much in advance.
the following script is on my "module:"
and I have this script on my "sheet 1:"Function CheckPath(strPath As String) As Boolean If Dir$(strPath) <> "" Then CheckPath = True Else CheckPath = False End If End Function
Private Sub commandbutton1_Click() Dim FileFolder As String FileFolder = "\\sptdsrefining.sabert.net/sites/ProductionSupervisors/HouseKeeping/Completed_Checklist\" & Range("E4").Value If CheckPath(FileFolder) = True Then 'Path exists, do what you want here ws As Worksheet, i As Long Set ws = Worksheets.Add For i = 1 To .FoundFiles.Count ws.Cells(i, 1) = Mid$(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1) Next Else 'Path does not exist, do what you want here MsgBox "No files found" End If End Sub





Reply With Quote