ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   On Error (https://www.excelbanter.com/excel-programming/280685-error.html)

TO

On Error
 
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

Kevin Stecyk

On Error
 
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



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




Don Guillett[_4_]

On Error
 
on error resume next

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




Don Guillett[_4_]

On Error
 
also


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




Tom Ogilvy

On Error
 
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

--
Regards,
Tom Ogilvy

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





All times are GMT +1. The time now is 07:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com