Error Handling problem
Not sure why excel is doing this... I have this code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 5/23/2005 by andya
Dim c As OLEObject
For x = 1 To Worksheets.Count
On Error GoTo ErrHand
For Each c In Worksheets(x)
'do stuff
Next c
ErrHand:
Next x
End Sub
This is what happens. When I step through the code the error handling works
fine when x=1. But on the next trip through (x=2), It gives me Run-time
error '438' on the "For Each c in Worksheets(x)" line and doesn't use the
error handling. Why?? Thanks for your help.
|