LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete broken named ranges in sheet

Hi Akyhne,

Just to add (and to complete my abnegation!), try running Peter's demo
'Test' macro, which defines various ranges and then intentionally breaks
some of the names.

Then run my macro and look at the Insert | Names | Define dialog.

Now run Peter's suggested routine and, again, check the Insert | Names |
Define dialog.


Does that clarify matters!


---
Regards,
Norman



"akyhne" wrote in message
...
Well, some of my names ARE referring to multi-area ranges, but still they
are
deleted correctly.

"Peter T" skrev:

Similar to Norman's but with InStr in case broken name refers to a
multi-area range -

Sub DelNames()
Dim n As Long
Dim nm As Name
Dim vArr()
n = 1
For Each nm In ActiveWorkbook.Names
If InStr(nm.RefersTo, "#REF!") Then
n = n + 1
ReDim Preserve vArr(1 To n)
vArr(n) = nm.Name
nm.Delete
End If
Next
If n 1 Then
vArr(1) = "Names deleted"
ActiveWorkbook.Worksheets.Add
Range("A1").Resize(n, 1).Value = Application.Transpose(vArr)
MsgBox "Find & rectify these names if used in formulas"
Else
MsgBox "No names deleted"
End If

End Sub

Sub Test()
With ActiveWorkbook
For i = 1 To 4
.Names.Add "myNameACE_" & i, Union([a1], [c1], [e1])
.Names.Add "myNameAE_" & i, Union([a1], [e1])
.Names.Add "myNameAC_" & i, Union([a1], [c1])
Next
Columns("C:C").Delete
End With

' DelNames
End Sub

Better still, use the NameManager addin which you can get from the
authors'
sites of Jan Karel Pieterse and Charles Williams:

www.jkp-ads.com
www.DecisionModels.com

Regards,
Peter T

"akyhne" wrote in message
...
How to delete broken named ranges in sheet?

When you manually delete rows or columns than contains named ranges,
the
named ranges in the deleted area is not deleted, but remains with a
faulty
reference as (Example): MYNAMEDRANGE =SHEETS!#REFERENCE!








 
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 unnecessary Named Ranges berniean Excel Discussion (Misc queries) 1 August 27th 09 07:24 PM
duplicate named ranges- how to detect, delete? Keith R Excel Discussion (Misc queries) 2 June 1st 07 04:41 PM
delete or edit named dell ranges chris31849 Excel Discussion (Misc queries) 5 March 9th 06 10:58 PM
How do I delete all named ranges in a sheet at one time? L.Wall Excel Worksheet Functions 2 July 13th 05 03:29 PM
Delete LOCAL named ranges Greg Excel Programming 2 December 9th 04 03:20 AM


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