Hello, I am running loop which check for specific files in specific folder. To find if any of the files missing, I created variable which stores the details of the missing file. To test my code I remove 2 files from set of 7 files I want to search through code. But variable which stored missing file details showed only one file name. So what changes I need to do in the following code.
Sub test()
wrkbk = Array("C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life 95.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life Dynamic Bond.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life Fornt Line Equity.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life Medium Term.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life MIP Wealth 25.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life Pure Value.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life Top 100.xlsm")
srch = Array("BIRLA SUN LIFE BALANCED 95 FUND", "BIRLA SUN LIFE DYNAMIC BOND FUND", _
"BIRLA SUN LIFE FRONTLINE EQUITY FUND", "BIRLA SUN LIFE MEDIUM TERM PLAN", _
"BIRLA SUN LIFE MIP WEALTH 25 PLAN", "BSL PURE VALUE FUND", _
"BIRLA SUN LIFE TOP 100 FUND")
For i = LBound(wrkbk) To UBound(wrkbk)
If Dir(wrkbk(i)) = "" Then
errm = srch(i) & " file not found" & vbNewLine
End If
Next
If errm <> "" Then
MsgBox errm
Else
MsgBox "All ok"
End If
End Sub
Sub test()
wrkbk = Array("C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life 95.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life Dynamic Bond.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life Fornt Line Equity.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life Medium Term.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life MIP Wealth 25.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life Pure Value.xlsm", _
"C:\Users\Vidyanand\Documents\Macro Prelive\Birla Sun Life Top 100.xlsm")
srch = Array("BIRLA SUN LIFE BALANCED 95 FUND", "BIRLA SUN LIFE DYNAMIC BOND FUND", _
"BIRLA SUN LIFE FRONTLINE EQUITY FUND", "BIRLA SUN LIFE MEDIUM TERM PLAN", _
"BIRLA SUN LIFE MIP WEALTH 25 PLAN", "BSL PURE VALUE FUND", _
"BIRLA SUN LIFE TOP 100 FUND")
For i = LBound(wrkbk) To UBound(wrkbk)
If Dir(wrkbk(i)) = "" Then
errm = srch(i) & " file not found" & vbNewLine
End If
Next
If errm <> "" Then
MsgBox errm
Else
MsgBox "All ok"
End If
End Sub