Option Explicit
-------------------------------------------
Sub findfileinfolder()
Call CountFiles
End Sub
---------------------------------------------
Private Function CountFiles()
Dim strDirectory As String, strDestFolder As String, strExt As String
strDirectory = InputBox("pl inter path for serch folder")
'strDestFolder = InputBox("pl inter path for output folder")
Dim myfilesystemobject As Object
Dim myfiles As Object
Dim myFile As Object
Dim Compld As Range
Dim mystore As Variant
Set myfilesystemobject = CreateObject("Scripting.FileSystemObject")
Set myfiles = myfilesystemobject.GetFolder(strDirectory).Files
For Each myFile In myfiles
Range("B1").ClearContents
Range("B1").Value = myFile.Name
mystore = myFile.Name
Set Compld = Range("A:A").Find(what:=mystore, LookIn:=xlValues, lookat:=xlWhole)
If Not Compld Is Nothing Then
'Stop
With myFile
.Copy strDestFolder & "\" & myFile.Name
End With
Else
End If
Next myFile
Set myfiles = Nothing
Set myfilesystemobject = Nothing
End Function
-------------------------------------------
Sub findfileinfolder()
Call CountFiles
End Sub
---------------------------------------------
Private Function CountFiles()
Dim strDirectory As String, strDestFolder As String, strExt As String
strDirectory = InputBox("pl inter path for serch folder")
'strDestFolder = InputBox("pl inter path for output folder")
Dim myfilesystemobject As Object
Dim myfiles As Object
Dim myFile As Object
Dim Compld As Range
Dim mystore As Variant
Set myfilesystemobject = CreateObject("Scripting.FileSystemObject")
Set myfiles = myfilesystemobject.GetFolder(strDirectory).Files
For Each myFile In myfiles
Range("B1").ClearContents
Range("B1").Value = myFile.Name
mystore = myFile.Name
Set Compld = Range("A:A").Find(what:=mystore, LookIn:=xlValues, lookat:=xlWhole)
If Not Compld Is Nothing Then
'Stop
With myFile
.Copy strDestFolder & "\" & myFile.Name
End With
Else
End If
Next myFile
Set myfiles = Nothing
Set myfilesystemobject = Nothing
End Function