View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Checking to see if a Range Object exists?

Hi debartsa

One way

Sub test()
Set Source = Nothing
On Error Resume Next
Set Source = Range("Activity")
On Error GoTo 0
If Source Is Nothing Then
MsgBox "The range don't exist.", _
vbOKOnly, "Hello"
Else
Range("Activity").Select
End If
End Sub

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"debartsa" wrote in message ...
Hi Everybody,

I'm using Excel 97 with VBA... Is there a way to programmatically check if a
named Range exists

i.e. I want to access === ActiveSheet.Range("Activity") <==== only
if it exists. The problem is it'll crash referencing this if it doesn't
exit?

Thanks for any help!
Sam