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: 411
Default Request for error handling tips

Hi James or anyone,

I'm attempting to understand error handling.

I copied this from James into a test worksheet and it produced runtime
error 1004, method range of object failed on Range(rgStr).Select

I used the procedure on a worksheet with data in range a1:h23.

Sub Sel()
Dim rgStr As String, c As Range
For Each c In Range("a1:h23")
If c < "" Then
If rgStr = "" Then
rgStr = c.Address
Else
rgStr = rgStr & "," & c.Address
End If
End If
Next c
Range(rgStr).Select
End Sub

With my limited knowledge I think this means there is no more data to
process in my range so the procedure produced the error. I figure the
procedure needs error handling.

I added On Error GoTo error_handler1 after the dim statement and
error_handler1: after Range(rgStr).Select.

The procedure still produces the same error dialog.

It seems to me that even if my error handler worked, I would lose the
values held in rgStr.

It also seems that since this procedure is returning values it should
be a function.

Please help clarify my understanding.

Dan Dungan

 
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 - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
Error Handling AA2e72E[_2_] Excel Programming 0 April 27th 04 04:06 PM
SQL.REQUEST #N/A error Stuk Excel Programming 5 February 28th 04 01:51 PM
Error Checking Tips Peter[_29_] Excel Programming 5 October 10th 03 05:27 PM


All times are GMT +1. The time now is 05:48 AM.

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

About Us

"It's about Microsoft Excel"