Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Error Trapping

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 ?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error Trapping

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

--
Regards,
Tom Ogilvy

"Neil" wrote in message
...
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 ?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Trapping gazza67[_2_] Excel Discussion (Misc queries) 2 September 6th 07 06:11 PM
Trapping #VALUE! error RhysPieces Excel Discussion (Misc queries) 6 August 22nd 07 03:13 AM
Error Trapping from WSH Tom Chau Excel Discussion (Misc queries) 1 August 25th 06 04:21 AM
error trapping flow23 Excel Discussion (Misc queries) 3 April 13th 06 04:51 PM
error trapping libby Excel Programming 5 November 25th 03 10:57 PM


All times are GMT +1. The time now is 07:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"