Private Sub CommandButton1_Click()
Dim FSO As Scripting.FileSystemObject, f As Scripting.File, Path As String
Dim BackupFiles() As String, ProdFiles() As String, index As Integer
Dim count1 As Integer, count2 As Integer, ProdFolder As String, BackupFolder As String
BackupFolder = "C:\"
ProdFolder = "C:\test"
Set FSO = CreateObject("Scripting.FileSystemObject")
ReDim BackupFiles(FSO.GetFolder(BackupFolder).Files.Count - 1, 1)
index = 0
'Get list of backup files
For Each f In FSO.GetFolder(BackupFolder).Files
BackupFiles(index, 0) = f.Name
index = index + 1
Next f
'Get list of Production files
index = 0
ReDim ProdFiles(FSO.GetFolder(ProdFolder).Files.Count - 1, 1)
For Each f In FSO.GetFolder(ProdFolder).Files
ProdFiles(index, 0) = f.Name
index = index + 1
Next f
'compare lists backupfolder to prodfolder
For count1 = 0 To UBound(BackupFiles)
For count2 = 0 To UBound(ProdFiles)
If BackupFiles(count1, 0) = ProdFiles(count2, 0) Then
BackupFiles(count1, 1) = "Found"
End If
Next count2
Next count1
'compare lists prodfolder to backupfolder
For count1 = 0 To UBound(ProdFiles)
For count2 = 0 To UBound(BackupFiles)
If ProdFiles(count1, 0) = BackupFiles(count2, 0) Then
ProdFiles(count1, 1) = "Found"
End If
Next count2
Next count1
'Output results
For count1 = 0 To UBound(BackupFiles, 1)
If BackupFiles(count1, 1) = "" Then
MsgBox "BackupFolder:" & BackupFiles(count1, 0) & " Not Found in ProdFolder"
Else
MsgBox "Backup Folder:" & BackupFiles(count1, 0) & " Found in Prodfolder"
End If
Next count1
For count1 = 0 To UBound(ProdFiles, 1)
If ProdFiles(count1, 1) = "" Then
MsgBox "ProdFolder:" & ProdFiles(count1, 0) & " Not Found in backupFolder"
Else
MsgBox "ProdFolder:" & ProdFiles(count1, 0) & " Found in backupfolder"
End If
Next count1
End Sub