PC Review


Reply
Thread Tools Rate Thread

Delete All Names - Even Invalid "#REF" Names

 
 
Brian B.
Guest
Posts: n/a
 
      2nd Apr 2007
FYI: The following code will delete all names in a workbook, including
those with a "#REF" error:

Sub Delete_Names()

Dim NameX As Name
On Error GoTo Nxt
For Each NameX In Names
ActiveWorkbook.Names(NameX.Name).Delete
Nxt:
Next NameX

End Sub

Adding the "On Error GoTo" will allow the code to also delete invalid
names too. I couldn't find this anywhere so I though I'd post it ...

-Brian

 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      2nd Apr 2007
To delete all names simply -

Dim nm as Name
for each nm in Activeworkbook.Names
nm.delete
Next

I can't think of anything that would raise an error doing this and require
some sort of error handler.

Regards,
Peter T


"Brian B." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> FYI: The following code will delete all names in a workbook, including
> those with a "#REF" error:
>
> Sub Delete_Names()
>
> Dim NameX As Name
> On Error GoTo Nxt
> For Each NameX In Names
> ActiveWorkbook.Names(NameX.Name).Delete
> Nxt:
> Next NameX
>
> End Sub
>
> Adding the "On Error GoTo" will allow the code to also delete invalid
> names too. I couldn't find this anywhere so I though I'd post it ...
>
> -Brian
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete emty file names from "recent documents" Excel Touble in Excel Microsoft Excel Misc 2 22nd Mar 2010 08:10 PM
Restrict Cached names "Suggest names while completing To ..." Corvette1964 Microsoft Outlook Discussion 2 24th Mar 2009 05:45 PM
Field Names: "LongName", "ShortName", "Code", "Description","Comments" PeteCresswell Microsoft Access 2 25th Feb 2009 11:41 PM
How to set "List Font names in their names" property in Word 2007 Test Engineer Microsoft Word Document Management 4 10th Apr 2008 11:06 AM
How do I delete names in "Select Names" list in Ouotlook? =?Utf-8?B?TGlzYVNlcmVuZQ==?= Microsoft Outlook Discussion 7 9th Oct 2007 04:25 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:54 PM.