Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Check to see if a range name exists on a sheet

I have the following expression in a line of code that I am writing. The
fld_name(colm) is an array of names that may be on a given sheet. The
statement results in an application defined error, since the fld_name(2) does
not exist. How do I check for the existence of a name?

I did search the general question and the programming groups, did not find a
close enough answer.

a1 = ActiveWorkbook.Names(fld_name(colm)).RefersTo
--
Sajit
Abu Dhabi
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Check to see if a range name exists on a sheet

Thanks Dave, I suppose there isn't a direct function that would tell this,
such as a isnull, isempty etc.
--
Sajit
Abu Dhabi


"Dave Peterson" wrote:

dim myName as Name
set myname = nothing
on error resume next
set myname = ActiveWorkbook.Names(fld_name(colm))
on error goto 0

if myname is nothing then
'it doesn't exist
else
a1 = myname.refersto
end if

===
Or you could do something like:

a1 = ""
on error resume next
a1 = ActiveWorkbook.Names(fld_name(colm)).RefersTo
on error goto 0

if a1 = "" then
'something bad happened
else
'do what you want
end if



Sajit wrote:

I have the following expression in a line of code that I am writing. The
fld_name(colm) is an array of names that may be on a given sheet. The
statement results in an application defined error, since the fld_name(2) does
not exist. How do I check for the existence of a name?

I did search the general question and the programming groups, did not find a
close enough answer.

a1 = ActiveWorkbook.Names(fld_name(colm)).RefersTo
--
Sajit
Abu Dhabi


--

Dave Peterson

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
How to check to see if a sheet with a particular name exists? Varun Excel Worksheet Functions 3 January 25th 09 01:41 PM
check if sheet exists mohavv Excel Discussion (Misc queries) 1 November 21st 07 01:58 AM
check if the sheet/tag exists Alex Excel Worksheet Functions 2 March 14th 06 08:58 PM
check to see if sheet exists Wandering Mage Excel Programming 1 September 28th 04 07:53 PM
check if sheet exists Ross[_6_] Excel Programming 3 July 25th 03 06:46 PM


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