Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Checking to see if a Range Object exists?

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Checking to see if a Range Object exists?

Thanks Ron,

I'll give it a try!

Sam


"Ron de Bruin" wrote in message
...
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






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
Checking to see if a file exists. JHB Excel Discussion (Misc queries) 3 August 5th 09 03:11 PM
Checking if Sheet Exists? [email protected] Excel Discussion (Misc queries) 5 September 1st 06 03:27 PM
Checking if file exists in VBA NADavies Excel Programming 3 October 23rd 03 02:16 PM
Checking to see if Folder exists Dan[_25_] Excel Programming 2 September 24th 03 02:42 AM
Checking 2 c if workbook exists DavidMc Excel Programming 4 September 5th 03 07:34 PM


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