I have an excel vba sub which checks if the file is in the said directory or not. The problem is it always goes to File Saved after the first iteration of the for loop. The value of the ActualValue
has some in it if the file is actually found, but if it is missing the value is "". The problem is it always go to the = 0 or = "" Condition.
Dim ActualValue As String
For i = 17 To 32
On Error Resume Next
DateFormat = Format("2017-12-11", "yyyy-mm-dd")
Sheet4.Cells(i, 5).Select
Selection.ClearContents
SearchValue = Sheet4.Cells(i, 1).Value
If SearchValue = "" Then
MsgBox "No A/C indicated. Please check.", vbOKOnly
Exit Sub
End If
ActualValue = Dir("A:\123 456\789\abc efg\Sample Folder\SAMPLE FOLDER\" & DateFormat & "\" & SearchValue & "" & "*.xls")
If Len(Dir(ActualValue)) = 0 Then
Sheet4.Cells(i, 10).Value = "File Saved"
Else
Sheet4.Cells(i, 10).Value = "File Missing"
GoTo FileMissing
End If
FileMissing:
Next i
Application.ScreenUpdating = True
End Sub