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: 11
Default Deleting Names in a Workbook

Hello,
I use names a lot in a workbook. When a worksheet is deleted, the names
remain. I would like to delete those that are valid. My thought was to
cycle through the names and try to go to the name. If an error is
caused, then delete the name. I used the code below but every name is
deleted. What am I doing wrong or is there an easier way to do this.

Thanks

Bill

Sub RemoveNamesNotThere()
nm = ActiveWorkbook.Names.Count
On Error GoTo 0
For j = nm To 1 Step -1
On Error Resume Next
NN = ActiveWorkbook.Names(j)
Application.Goto Reference:=NN
If Err < 0 Then
ActiveWorkbook.Names(j).Delete
End If
On Error GoTo 0
Next j
CS.Activate
End Sub


*** Sent via Developersdex http://www.developersdex.com ***
 
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 unused Defined Names in a workbook? Mike Piazza Excel Programming 0 May 13th 05 03:18 PM
Deleting Names Rob Bovey Excel Programming 0 September 14th 04 08:30 PM
Deleting workbook names w/ VB Big-E Excel Programming 6 April 28th 04 07:01 PM
deleting workbook names in excel Liz Gewirtz Excel Programming 1 November 7th 03 01:42 PM


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