Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Delete All Names - Even Invalid "#REF" Names

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Delete All Names - Even Invalid "#REF" Names

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." wrote in message
ups.com...
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
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
Delete emty file names from "recent documents" Excel Touble in Excel Excel Discussion (Misc queries) 2 March 22nd 10 08:10 PM
Delete "Unused names" in a batch D0306 Excel Discussion (Misc queries) 2 July 18th 07 04:40 PM
Help,, need macro to replace 'space' in list of names with "." (dot), then compare ss jay Excel Programming 0 February 23rd 06 05:33 PM
How do you hide macro names from showing in "Tools"? Nashua Excel Programming 1 November 9th 05 03:50 PM
Backup to specific folder if workbook names begins with "NSR" or "MAC" GregR Excel Programming 3 May 6th 05 12:24 AM


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