LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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.


 
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
Error handling problem Jim G Excel Discussion (Misc queries) 2 October 3rd 07 02:19 AM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
Error Handling Problem Minitman[_4_] Excel Programming 3 November 15th 04 06:52 AM
Excel VBA - Error handling problem brutalmetal[_2_] Excel Programming 2 January 21st 04 03:17 AM
Error Handling Bill Lunney Excel Programming 0 August 6th 03 11:56 PM


All times are GMT +1. The time now is 06:24 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"