Error Trapping

  • Thread starter Thread starter Neil
  • Start date Start date
N

Neil

Hi, I have a data table that has file path and name
information, I am running a loop across it which opens up
each path&filename, reads in some data from the file into
an array, then closes the file and dumps the contents of
the array into my spreadsheet. This all works fine but I
want to error trap if a user deletes on of the files, I
can use the on error statement, but the fileopen
statement is in the loop, and once I go out of the loop
to the error code I dont know how to get back to the
correct place in my original loop ?
 
why not avoid the error - don't try to open a missing file

sPath = "C:\My Documents"
for each cell in Range("A1:A10")
sStr = sPath & "\" & Cell.Value
if dir(sStr) <> "" then
' file exists, open it
end if
Next
 
Back
Top