Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Deleting names with errors

Hi all

Is there a quick and easy VBA method of deleting all names that contain
errors?
I don't mean EVALUATE to errors, that would be too difficult.
I mean if I have a name that contains
=#REF!$A$1:$A$100
or
=#N/A
etc

Thanks

--
Return email address is not as DEEP as it appears


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Deleting names with errors

Hi Jack,

Is there a quick and easy VBA method of deleting all names that contain
errors?
I don't mean EVALUATE to errors, that would be too difficult.
I mean if I have a name that contains
=#REF!$A$1:$A$100


Consider downloading the
Name manager (by Charles Williams, Matthew Henson and
myself) from:

www.jkp-ads.com/Download.htm

or

www.oaltd.ie/mvp

or from:

www.decisionmodels.com/downloads.htm

You can filter the list of names for those containing errors and then do
anything you want with them.

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Deleting names with errors

Hi Jan

Yes, I already use that a lot, and it is really GREAT!

But it does not help my particular case:

Embedded within a workbook I have macros the execution of which result in
the generation of unwanted names (usually the macro involves some worksheet
duplication or deletion, and those worksheets refer to names local to other
worksheets, resulting in some "white noise" appearing in the list of names).

I want to include some additional code within the existing macros, so as to
"clean up" (ie discard) the surplus names. I am fairly confident that if I
delete all names containing errors that would do most of the work required.

I would not know how to call features of Name Manager from within a VBA
routine, and anyway I would want to distribute the workbook to others who
might not have Name Manager.

"Jan Karel Pieterse" wrote in message
...
Hi Jack,

Is there a quick and easy VBA method of deleting all names that contain
errors?
I don't mean EVALUATE to errors, that would be too difficult.
I mean if I have a name that contains
=#REF!$A$1:$A$100


Consider downloading the
Name manager (by Charles Williams, Matthew Henson and
myself) from:

www.jkp-ads.com/Download.htm

or

www.oaltd.ie/mvp

or from:

www.decisionmodels.com/downloads.htm

You can filter the list of names for those containing errors and then do
anything you want with them.

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Deleting names with errors

Hi Jack,

I want to include some additional code within the existing macros, so as to
"clean up" (ie discard) the surplus names. I am fairly confident that if I
delete all names containing errors that would do most of the work required.


You could use something like this (untested):

Sub RemoveNamesWithErrors(oWkbk as Workbook)
Dim oNm as Name
For Each Onm in oWkbk.Names
If Instr("#Ref!",Onm.Refersto)0 Then
Onm.Delete
End If
Next
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Deleting names with errors

Thanks
This seems to be close. Just one problem:
One of the surplus names that is created refers to #N/A
I tried adding the line
If Instr("#N/A",Onm.Refersto)0 Then Onm.Delete
immediately after the test for #REF!
but it does not delete that name.
Any suggestions? Thanks

"Jan Karel Pieterse" wrote in message
...
Hi Jack,

I want to include some additional code within the existing macros, so as

to
"clean up" (ie discard) the surplus names. I am fairly confident that

if I
delete all names containing errors that would do most of the work

required.


You could use something like this (untested):

Sub RemoveNamesWithErrors(oWkbk as Workbook)
Dim oNm as Name
For Each Onm in oWkbk.Names
If Instr("#Ref!",Onm.Refersto)0 Then
Onm.Delete
End If
Next
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Deleting names with errors

Hi Jack,

I tried adding the line
If Instr("#N/A",Onm.Refersto)0 Then Onm.Delete
immediately after the test for #REF!
but it does not delete that name.


Change this line in my original code :

If Instr("#Ref!",Onm.Refersto)0 Then

To:

If Instr("#Ref!",Onm.Refersto)0 Or Instr("#N/A!",Onm.Refersto)0 Then

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

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
deleting names from the name box Amy C Excel Discussion (Misc queries) 4 May 12th 06 11:00 AM
deleting duplicate names torbau Excel Discussion (Misc queries) 0 March 8th 06 04:59 PM
deleting duplicate names chris Excel Worksheet Functions 1 February 16th 06 08:42 PM
Deleting Names Rob Bovey Excel Programming 0 September 14th 04 08:30 PM
Deleting range names CiaraG[_4_] Excel Programming 1 May 10th 04 04:39 PM


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

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"