VBA search string and substring
<p>I have to search and copy a number of files in a folder starting from an Excel list like:</p>

<pre><code>8100
8152
8153
</code></pre>

<p>in the folder there are files named like this:</p>

<pre><code>8100.pdf
100_8152.pdf
102_8153.pdf
8153 (2).pdf
</code></pre>

<p>How can I search these files without renaming all the files?
Thanks to user3598756, this is the code I'm now using for searching files with the same name in excel list and in the file folder:</p>

<pre><code>Option Explicit

Sub cerca()
Dim T As Variant
Dim D As Variant

T = VBA.Format(VBA.Time, "hh.mm.ss")
D = VBA.Format(VBA.Date, "yyyy.MM.dd")

Dim Source As String
Dim Dest As String
Dim Missed As String
Dim fileFound As String
Dim CodiceCS As Variant
Dim cell As Range

Source = "D:\myfolder\"
Dest = "D:\myfolder\research " &amp; D &amp; " " &amp; T

If Dir(Dest, vbDirectory) = "" Then MkDir Dest '&lt;--| create destination folder if not alerady there

With Worksheets("Cerca") '&lt;-- reference your worksheet with pdf names
    For Each cell In .Range("A2", .Cells(.Rows.Count, "A").End(xlUp)).SpecialCells(xlCellTypeConstants) '&lt;-- loop through its column "A" cells with "constant" (i.e. not resulting from formulas) values from row 2 down to last non empty one
        CodiceCS = VBA.Left((cell.Value), 4)
        fileFound = Dir(Source &amp; "\" &amp; CodiceCS &amp; "\*" &amp; cell.Value &amp; "*.Pdf") '&lt;-- look for a source folder file whose name contains the current cell value
        If fileFound &lt;&gt; "" Then '&lt;-- if found...
            FileCopy Source &amp; "\" &amp; CodiceCS &amp; "\" &amp; fileFound, Dest &amp; "\" &amp; fileFound '&lt;-- ...copy to destination folder
        Else '&lt;--otherwise...
            Missed = Missed &amp; cell.Value &amp; vbCrLf '&lt;--... update missing files list
        End If
    Next cell
End With

If Missed &lt;&gt; "" Then '&lt;-- if there's any missing file
    Dim FF As Long
    FF = FreeFile

    Open (Dest &amp; "\" &amp; "MissingFiles.txt") For Output As #FF
    Write #FF, VBA.Left(Missed, Len(Missed) - 2)
    Close #FF
End If

MsgBox "OK"
Shell "explorer.exe " + Dest, vbNormalFocus

End Sub
</code></pre>

<p>The code works with all files with prefix but not with files with suffix (ie: "8153 (2).pdf"). The code returns only one file, but I need All the files matching the cell value. I need to extend my research in subfolders organized by years too (ie: "D:\myfolder\2015", "D:\myfolder\2016", etc.).</p>