Hi Team,
I want VBA Function which will check whether all required input files present in a folder.
if files missing highlight missing files.
Below are Main Key words to check
Debtors
Creditors
Overdue
Recon
Sales Register.
Below attmpted code, not giving correct result. I am ok with any other way.
I want VBA Function which will check whether all required input files present in a folder.
if files missing highlight missing files.
Below are Main Key words to check
Debtors
Creditors
Overdue
Recon
Sales Register.
Below attmpted code, not giving correct result. I am ok with any other way.
VBA Code:
Sub Check_Files()
Dim Filenames As String
Dim path As String
Filenames = "Debtors,Creditors,Overdue,Recon,Sales Register"
path = "C:\Users\ASUS\Desktop\Reconcilation\"
If Not Files_Check(path, Filenames) Then
MsgBox "Files not found" & Chr(10) & Filenames, 16, "Files Missing in " & path
End If
End Sub
Function Files_Check(ByVal path As String, ByRef Filenames As String) As Boolean
Dim arFilename() As String
arFilename = Split(Filenames, ",")
Dim filesnames As String
Dim i As Long
Dim str As String
str = ""
Dim strFile As String
For i = 0 To UBound(arFilename)
strFile = "*" & arFilename(i) & "*.xlsx"
Filenames = Dir(path & strFile)
If Len(Filenames) = 0 Then
Filenames = Filenames & "," & arFilename(i)
End If
Next i
Files_Check = CBool(Len(Filenames) = 0)
End Function