I was able to figure out a way for the program to loop through the folder, but I am having trouble having it loop through the subfolders in the main directory.
Sub SearchDeviceFile()
Dim fso, fldr, fil, myfolder As Object
Dim wb As Workbook
Dim devfile As String
Dim d As String, ext, x
Dim srcPath As String, destPath As String, srcFile As String
Set fso = CreateObject("scripting.filesystemobject")
Set fldr = fso.getfolder(Dir("C:\*", vbDirectory))
srcPath = fldr & "\"
destPath = "C:\UNM1\"
ext = Array("*History(Device)*.csv")
For Each x In ext
d = Dir(srcPath & x)
Do While d <> ""
srcFile = srcPath & d
FileCopy srcFile, destPath & d
d = Dir
Loop
Next
End Sub
Bookmarks