Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 454
Default Code to Delete Range Names

Would anyone have some code that I could run to delete all named ranges
on all woksheets within a file?


Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Code to Delete Range Names

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" wrote in message
oups.com...
Would anyone have some code that I could run to delete all named ranges
on all woksheets within a file?


Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 454
Default Code to Delete Range Names

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" wrote in message
oups.com...
Would anyone have some code that I could run to delete all named ranges
on all woksheets within a file?


Thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Code to Delete Range Names

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" wrote in message
oups.com...
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" wrote in message
oups.com...
Would anyone have some code that I could run to delete all named ranges
on all woksheets within a file?


Thanks




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
How to Delete blanks between a range and populate only the names inthe given range Yuvraj Excel Discussion (Misc queries) 2 November 4th 09 08:32 PM
How to delete a hundred range names at once? Dima Excel Worksheet Functions 4 August 7th 08 11:26 AM
delete non-used range names TxRaistlin Excel Programming 3 July 19th 06 09:05 AM
Delete Specific Range Names Larry[_11_] Excel Programming 3 December 22nd 03 09:48 PM
How do I delete ExternalRata range names? Nathan Gutman Excel Programming 2 December 18th 03 09:02 PM


All times are GMT +1. The time now is 05:11 AM.

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"