有这么个函数就简单啦
Sub Macro1()
Dim p$, f$, Fso As Object, sFileType$, i&, arr$(), brr$(), m&
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = False Then Exit Sub
p = .SelectedItems(1) & "\"
End With
sFileType = "*.jpg"
Set Fso = CreateObject("Scripting.FileSystemObject")
Call GetFiles(p, sFileType, Fso, arr, m)
W = Range("A65536").End(3).Row
If W = 2 Then Exit Sub
For J = 2 To W
For i = 1 To m
If arr(2, i) = Cells(J, 1) & ".jpg" Then
f = arr(1, i) & Application.Clean(Cells(J, 3).Value) & ".jpg"
If Dir(f) <> "" Then
MsgBox Cells(J, 3) & ".jpg 已存在"
GoTo 10
End If
Name arr(1, i) & arr(2, i) As f
Exit For
End If
Next
10 Next
MsgBox "处理完毕", vbInformation
Set Fso = Nothing
End Sub