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: 1
Default Names.add - Test to see if name already exists?


The intent is if a name does not exist to create it. Then set or change
the address it points to.

I am using the line of code below to change the address that the name
points to (when it is created by Insert-Name-Define menus).

Names(sFromSheet & aMonths(1) & aYears(i)).RefersTo = "=" &
Selection.Address

If the name does not exist it stops with an error.

-------
When I try to test if the name exists:

If Names(sFromSheet & aYears(i)) Then
'Nothing to do it is in existance
Else
Names.Add sFromSheet & aMonths(1) & aYears(i)
End If

I get an Application-Defined or ObjectiDefeined Error on the If
statement. I get the same error when I add the worksheet name as a
preface.

If Names(sFromSheet & "!" & sFromSheet & aYears(i)) Then
'Nothing to do it is in existance
Else
Names.Add sFromSheet & aMonths(1) & aYears(i)
End If
What am I doing wrong? I am completly lost again! But I am learning!

Thanks in advance- Craigm


--
Craigm
------------------------------------------------------------------------
Craigm's Profile: http://www.excelforum.com/member.php...o&userid=24381
View this thread: http://www.excelforum.com/showthread...hreadid=537707

 
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
Test if file exists Daniel Bonallack Excel Discussion (Misc queries) 2 May 4th 09 04:19 PM
How to test if a DLL (library) exists ExcelMonkey Excel Programming 2 August 7th 05 08:14 PM
Test for Worksheet Exists bcmiller[_8_] Excel Programming 4 July 2nd 04 11:46 AM
Test if a folder exists, create if it doesn't? 43fan Excel Programming 3 March 1st 04 02:59 PM
Test if a folder exists Jeff Marshall Excel Programming 6 September 30th 03 05:21 PM


All times are GMT +1. The time now is 10:43 PM.

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

About Us

"It's about Microsoft Excel"