Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Finding a Range Name

Hi,

The code below when finding the Range Name and when the name is exists on
the sheet it runs ok but when it does not find the Range Name ("Stop") it
blows up with a run time error that reads 'Global Method Failed'

Can someone help and show me what is wrong or the proper way to code this.


If Not Range(Range("D101"), Range("D65536")) _
.Find(Range("Stop")) Is Nothing Then GoTo NextStep
(MyCode)
Exit Sub
NextStep:
(MyCode)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding a Range Name


You just need an error-handling event in the code.
This On Error will trigger the procedure to end

Sub ProcedureName
On Error Goto MyErrorHandler

//
your code here
//
Exit Sub
MyErrorHandler:
End Su

--
crispb
-----------------------------------------------------------------------
crispbd's Profile: http://www.excelforum.com/member.php...fo&userid=1088
View this thread: http://www.excelforum.com/showthread.php?threadid=27419

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Finding a Range Name

Dim rng as Range, rng1 as Range
on Error Resume next
set rng = Range("Stop")
on Error goto 0
if not rng is nothing then
set rng1 = Range("D101:D65536") _
.Find(rng.Value)
if not rng1 is nothing then
' now you can run your code and
' use rng1 if you need to
end if
end if
Next Step:

Not sure what action should be taken if Range("Stop") is not found, but the
above portion of code won't blow up.

--
Regards,
Tom Ogilvy

"James Montgomery" wrote in message
...
Hi,

The code below when finding the Range Name and when the name is exists on
the sheet it runs ok but when it does not find the Range Name ("Stop") it
blows up with a run time error that reads 'Global Method Failed'

Can someone help and show me what is wrong or the proper way to code this.


If Not Range(Range("D101"), Range("D65536")) _
.Find(Range("Stop")) Is Nothing Then GoTo NextStep
(MyCode)
Exit Sub
NextStep:
(MyCode)




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Finding a Range Name

Thanks for all help
James

"James Montgomery" wrote in message
...
Hi,

The code below when finding the Range Name and when the name is exists on
the sheet it runs ok but when it does not find the Range Name ("Stop") it
blows up with a run time error that reads 'Global Method Failed'

Can someone help and show me what is wrong or the proper way to code this.


If Not Range(Range("D101"), Range("D65536")) _
.Find(Range("Stop")) Is Nothing Then GoTo NextStep
(MyCode)
Exit Sub
NextStep:
(MyCode)




Reply
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
Finding the corresponding value in a range? Zuo Excel Worksheet Functions 4 February 25th 10 12:45 PM
Finding a value associated with a range Raymond Gallegos Excel Worksheet Functions 5 November 25th 05 08:38 PM
finding name within range sheila Excel Worksheet Functions 4 September 14th 05 07:52 AM
finding if name within range sheila Excel Worksheet Functions 9 September 13th 05 04:24 AM
Finding from a range Mark[_50_] Excel Programming 1 August 26th 04 12:19 PM


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