View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
BRC[_2_] BRC[_2_] is offline
external usenet poster
 
Posts: 19
Default deleting named ranges on a worksheet (not workbook)

On Jan 9, 2:22*pm, "Rick Rothstein"
wrote:
Give this a try...

Sub DeleteNamesFromActiveSheet()
* Dim N As Name
* For Each N In ActiveWorkbook.Names
* * If N.RefersToRange.Parent.Name = ActiveSheet.Name Then N.Delete
* Next
End Sub

As constructed, it removes the names from the ActiveSheet, but you can make
the obvious change if you want to remove the names from a specified
worksheet instead of the ActiveSheet.

--
Rick (MVP - Excel)

"BRC" wrote in message

...



Hi *All
I am writhing a routine that takes a data set that is pasted in and
then does several calculations. *in the process it defines several
ranges. *I would like to have a line of code (or subroutine)that would
delete any named ranges in the worksheet to make certian we are
starting with clean sheet. *Any help is appreciated. Thanks BRC- Hide quoted text -


- Show quoted text -


Thank you all for the input. I used Don's code and it seems to work
fine. I did have to change the string read from 2 to 3. I am using
excel 2007 and it appears that range names in this version are
preceded by....='.... and the names start at the 3rd character. thanks
again.