Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error handling skipping file help

Status
Not open for further replies.

eHanSolo

Technical User
May 24, 2004
260
GB
Hey guys,

Need a bit of a tip here.

I'm basically asking my code to compare the dates i have in column A1 to the file names (which happen to be dates as well) in a specified directory.

It all works fine except when it comes across a date in col A1 that doesn't exist in the specified directory then it falls over.

Basically, I'd like it to skip to the next date if it can't find it...and if the next date isn't there then skip until it does and then carry on with whatever it was doing.

I'm thinking along the lines of On Error do bla bla bla...but i'm not sure how to achieve this. Please help!!


 
If I understand correctly you can either use;

On Error Resume Next before the line of code that is causing the error.

Or you can check to see if the line you are checking is a date or is blank

If Not IsNull(variable_to_check) Then
If IsDate(variable_to_check) Then
Do_What_You_Gotta_Do
End If
End If

HTH
 
Something like this ?
Before the Loop in column A:
On Error Resume Next
After the test for filename:
If Err.Number <> 0 Then
Err.Clear
Else
' your actual code here
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top