this macro displays the correct names from a file list but i need it to display the missing files not the existing ones and ideas of how to change it to make that happen?
VBA Code:
Sub MatchingValues()
Dim DirectoryListArray As Variant, sPath As String
Dim rg As Range, i As Long, j As Long
Dim ListBox1 As Variant
sPath = "C:\Users\jbeehler.fzrpa\Desktop\auto\"
DirectoryListArray = GetFiles(sPath)
Set rg = Worksheets("Data List").Cells(1, 1).CurrentRegion
With CreateObject("Scripting.Dictionary")
For i = 0 To UBound(DirectoryListArray)
For j = 2 To rg.Rows.Count
If Not rg.Cells(j, 6) = vbNullString Then
If InStr(1, DirectoryListArray(i), rg.Cells(j, 6)) > 0 Then
.Item(rg.Cells(j, 3).Value) = Empty
End If
End If
Next j
Next i
ListBox1 = .Keys
End With
MsgBox Join(ListBox1, vbLf) 'Adapt to your needs
End Sub
Function GetFiles(sPath As String) As Variant
Dim sFileName As String
With CreateObject("Scripting.Dictionary")
sFileName = Dir(sPath, vbNormal)
Do While Not sFileName = vbNullString
.Item(sFileName) = Empty
sFileName = Dir
Loop
GetFiles = .Keys
End With
End Function