Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to delete only all damaged defined ranges in book

How could the sub below be amended so that
it deletes only the defined ranges which are damaged/destroyed, eg:
MyT =#REF!$A$1:$A$6

while leaving valid ones intact, eg:
MyT2 =Sheet2!$A$1:$A$3

Currently it removes everything. Thanks.

Sub DeleteNames()
Dim nm As Object
For Each nm In ActiveWorkbook.Names
nm.Delete
Next
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default Sub to delete only all damaged defined ranges in book

Hi max

if you want to check for #REF you could do following:

For Each nm In ActiveWorkbook.Names
Debug.Print nm.Name
If InStr(1, nm, "#REF") Then nm.Delete
Next nm

hth

Carlo

On Jan 8, 10:37*am, "Max" wrote:
How could the sub below be amended so that
it deletes only the defined ranges which are damaged/destroyed, eg:
MyT =#REF!$A$1:$A$6

while leaving valid ones intact, eg:
MyT2 =Sheet2!$A$1:$A$3

Currently it removes everything. Thanks.

Sub DeleteNames()
Dim nm As Object
* * For Each nm In ActiveWorkbook.Names
* * * * nm.Delete
* * Next
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to delete only all damaged defined ranges in book

Thanks, Carlo! That works well.


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
reset defined ranges Greg Excel Discussion (Misc queries) 3 May 11th 10 10:38 PM
summing to defined ranges keerthyV Excel Worksheet Functions 2 April 8th 09 08:05 AM
Excessive Defined Names Causing Book Properties not to work properly Ronald Dodge[_2_] Excel Programming 5 May 3rd 07 07:24 PM
dynamic defined ranges Thomas Pike Excel Worksheet Functions 1 September 14th 05 12:29 AM
defined name ranges Ben Excel Programming 5 August 19th 05 08:43 PM


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