Thread: Clearing Errors
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jswalsh33 jswalsh33 is offline
external usenet poster
 
Posts: 51
Default Clearing Errors


I have tried hard to make this code work but I have not been successful.

Sheets("CustData").Activate
Num = Sheets("CustData").Range("DG5001")
For x = 1 To 4
If x = 1 Then CustN = Sheets("OrderEntry").Range("D7") Else CustN =
Sheets("OrderEntry").Cells((x - 2) * 14 + 23, 4)
Sheets("CustData").Range(Cells(6, 1), Cells(Num + 10, 1)).Select
On Error GoTo Line2
Selection.Find(What:=CustN, After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
Row = ActiveCell.Row
Sheets("CustData").Range(Cells(Row, 1), Cells(Row, 110)).ClearContents
Sheets("CustData").Cells(Row, 112).ClearContents
Line2:
If Err.Number < 0 Then Err.Clear
Next x

In this example CustN="" for all x's.
The code works fine for the first x. It jumps to Line2 and proceeds to the
next x.

However the "Find" line fails with a runtime error 91 when x =2, 3 or 4.

What am I doing wrong?

Thanks for your help.

Jim Walsh