#1   Report Post  
Posted to microsoft.public.excel.programming
TO TO is offline
external usenet poster
 
Posts: 6
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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





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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
Error: "Excel encountered an error and had to remove some formatti Carl Excel Discussion (Misc queries) 0 September 18th 06 06:39 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM


All times are GMT +1. The time now is 08:20 AM.

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

About Us

"It's about Microsoft Excel"