On Error

T

TO

I have book where I open workbooks based on a filenames
contained in a column. When the file is opened code runs
and perfoms various operations. The next cell in the
column becoms the target filename and that file is opened
and data is extracted.

The problem I have is that the filenames in the column do
not always match the files in the destination folder.

If there is a filename but no actual file, I would like
to skip all the following code and go to the next cell
(new filename) and open etc. I tried using "On Error
GoTo". This works unless there are two consecutive "bad"
filenames.

Thanks in advance
 
K

Kevin Stecyk

To,

You should post the appropriate snippet of code. You should be looping, so
it ought not be a problem. But if you post your code, I am sure someone
will spot your error.

Regards,
Kevin
 
T

Tom Ogilvy

Instead of using error handling, just check if the file exist and put your
code inside and If ... End if Statement

if dir(cell.Value) <> "" then
' file was found, code to open and work with it


End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top