PC Review


Reply
Thread Tools Rate Thread

Code to Delete Range Names

 
 
Sean
Guest
Posts: n/a
 
      3rd Jan 2007
Would anyone have some code that I could run to delete all named ranges
on all woksheets within a file?


Thanks

 
Reply With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      3rd Jan 2007
To remove the names, but leave the data intact:

For Each nName In ActiveWorkbook.Names
nName.Delete
Next

To clear the ranges of data but leave the names:

For Each nName In ActiveWorkbook.Names
On Error Resume Next
nName.RefersToRange.ClearContents
On Error Goto 0
Next

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Sean" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Would anyone have some code that I could run to delete all named ranges
> on all woksheets within a file?
>
>
> Thanks
>



 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      3rd Jan 2007
Thanks Jon, its just to remove the names and leave everthing else
intact. I'll get it a go


Jon Peltier wrote:

> To remove the names, but leave the data intact:
>
> For Each nName In ActiveWorkbook.Names
> nName.Delete
> Next
>
> To clear the ranges of data but leave the names:
>
> For Each nName In ActiveWorkbook.Names
> On Error Resume Next
> nName.RefersToRange.ClearContents
> On Error Goto 0
> Next
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> http://PeltierTech.com
> _______
>
>
> "Sean" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Would anyone have some code that I could run to delete all named ranges
> > on all woksheets within a file?
> >
> >
> > Thanks
> >


 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      3rd Jan 2007
if for some reason you wanted to make a backup of the ranges, or maybe duplicate
ranges from one workbook to another, you could use this. then just take the
output of the immediate window, paste it in a sub and run it to re-create the
ranges. sheet names would obviously have to be identical.

Sub BackupRanges()
Dim nm As Name
sName = ActiveSheet.Name
For Each nm In ThisWorkbook.Names
Debug.Print "ActiveWorkbook.Names.Add Name:=" & """" & nm.Name & """" & _
", Refersto:=""" & nm
Next
End Sub
--


Gary


"Sean" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Jon, its just to remove the names and leave everthing else
> intact. I'll get it a go
>
>
> Jon Peltier wrote:
>
>> To remove the names, but leave the data intact:
>>
>> For Each nName In ActiveWorkbook.Names
>> nName.Delete
>> Next
>>
>> To clear the ranges of data but leave the names:
>>
>> For Each nName In ActiveWorkbook.Names
>> On Error Resume Next
>> nName.RefersToRange.ClearContents
>> On Error Goto 0
>> Next
>>
>> - Jon
>> -------
>> Jon Peltier, Microsoft Excel MVP
>> Tutorials and Custom Solutions
>> http://PeltierTech.com
>> _______
>>
>>
>> "Sean" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Would anyone have some code that I could run to delete all named ranges
>> > on all woksheets within a file?
>> >
>> >
>> > Thanks
>> >

>



 
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
How to Delete blanks between a range and populate only the names inthe given range Yuvraj Microsoft Excel Misc 2 4th Nov 2009 08:32 PM
Delete all Range Names Q Seanie Microsoft Excel Programming 5 11th Jan 2009 08:35 PM
Delete all Range Names Except for 1 Q Sean Microsoft Excel Programming 2 16th Jan 2007 04:27 PM
delete non-used range names =?Utf-8?B?VHhSYWlzdGxpbg==?= Microsoft Excel Programming 3 19th Jul 2006 09:05 AM
Range Names quick delete Nick Microsoft Excel Misc 4 30th Aug 2004 10:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:56 PM.