I am using a macro to automate an openfile from files ina specific directory. The file contains the date in the yyyymmdd format which isnt a problem. im iteratioing through the file searching for a file containing any of the last nine days as follows:
Sub test()
Dim i As Integer
Dim xlFileName As String
i = 0
ChDrive "E" ' set default drive
ChDir "E:\test"
While i < 9
xlFileName = "anc" & Format$(Now - i, "yyyymmdd") & "Sales.xls"
If (xlFileName = True) Then ***this part is where I am having difficulties, dont know how to test its existance
msgbox 'just to see if it work or not
End If
i = i + 1
Wend
End Sub
Sub test()
Dim i As Integer
Dim xlFileName As String
i = 0
ChDrive "E" ' set default drive
ChDir "E:\test"
While i < 9
xlFileName = "anc" & Format$(Now - i, "yyyymmdd") & "Sales.xls"
If (xlFileName = True) Then ***this part is where I am having difficulties, dont know how to test its existance
msgbox 'just to see if it work or not
End If
i = i + 1
Wend
End Sub