I am currently running a macro that searches for a file with a rotating filename.
The current code I am using works fine. However it returns and opens multiple files. I am using numerous search criteria as the file changes daily based on the time it was saved. I am trying to figure a way to stop the search once it finds a match and continue on with the rest of the macro.
Dim FileDate As String
FileDate = Application.InputBox("Please enter file date: (MM/DD/YYYY)")
On Error Resume Next
c00 = "\\wpccp001if\Apps\C3PO\PMG - Ben's\Network MPT Inclusion\ECMReports_Daily\"
c01 = c00 & Format((FileDate), "yyyymmdd")
Workbooks.Add c00 & Dir(c01 & " 220*campdata.csv")
If Err.Number > 0 Then Workbooks.Add c00 & Dir(c01 & " 215*campdata.csv")
If Err.Number > 0 Then Workbooks.Add c00 & Dir(c01 & " 214*campdata.csv")
If Err.Number > 0 Then Workbooks.Add c00 & Dir(c01 & " 213*campdata.csv")
If Err.Number > 0 Then Workbooks.Add c00 & Dir(c01 & " 210*campdata.csv")
If Err.Number > 0 Then Workbooks.Add c00 & Dir(c01 & " 205*campdata.csv")
If Err.Number > 0 Then Workbooks.Add c00 & Dir(c01 & " 204*campdata.csv")
If Err.Number > 0 Then Workbooks.Add c00 & Dir(c01 & " 203*campdata.csv")
Bookmarks