Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Deleting worksheet specific range names

I have a datasheet with a list of worksheet range names that I want to
delete. The sheet name is in column A and the range name is in column B. I
have the following
code. What do I need to change to get the range names to be deleted?

datasheet = ActiveSheet.Name
CurBook = Application.ActiveWorkbook.Name

For i = 3 To 48
rangename = Workbooks(CurBook).Worksheets(datasheet).Range("b" & i).Value
sht = Workbooks(CurBook).Worksheets(datasheet).Range("a" & i).Value
CurBook.Worksheet(sht).Names(rangename).Delete
Next i

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Deleting worksheet specific range names

Sub Delete_Names()
Dim n As Name
For Each n In ActiveWorkbook.Names
n.Delete
Next n
End Sub

--
Gary's Student


"Barb Reinhardt" wrote:

I have a datasheet with a list of worksheet range names that I want to
delete. The sheet name is in column A and the range name is in column B. I
have the following
code. What do I need to change to get the range names to be deleted?

datasheet = ActiveSheet.Name
CurBook = Application.ActiveWorkbook.Name

For i = 3 To 48
rangename = Workbooks(CurBook).Worksheets(datasheet).Range("b" & i).Value
sht = Workbooks(CurBook).Worksheets(datasheet).Range("a" & i).Value
CurBook.Worksheet(sht).Names(rangename).Delete
Next i

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Deleting worksheet specific range names

That would work if I wanted to delete all the workbook names in the workbook.
I didn't. Peter T had the response I needed.

"Gary''s Student" wrote:

Sub Delete_Names()
Dim n As Name
For Each n In ActiveWorkbook.Names
n.Delete
Next n
End Sub

--
Gary's Student


"Barb Reinhardt" wrote:

I have a datasheet with a list of worksheet range names that I want to
delete. The sheet name is in column A and the range name is in column B. I
have the following
code. What do I need to change to get the range names to be deleted?

datasheet = ActiveSheet.Name
CurBook = Application.ActiveWorkbook.Name

For i = 3 To 48
rangename = Workbooks(CurBook).Worksheets(datasheet).Range("b" & i).Value
sht = Workbooks(CurBook).Worksheets(datasheet).Range("a" & i).Value
CurBook.Worksheet(sht).Names(rangename).Delete
Next i

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Deleting worksheet specific range names

Assuming 'rangename' is returning a valid Worksheet level name for 'sht' try
changing

CurBook.Worksheet(sht).Names(rangename).Delete


Workbooks(CurBook).WorksheetS(sht).Names(rangename ).Delete

Rather than Workbooks(CurBook) you could set a reference to the workbook.

Regards,
Peter T

"Barb Reinhardt" wrote in message
...
I have a datasheet with a list of worksheet range names that I want to
delete. The sheet name is in column A and the range name is in column B.

I
have the following
code. What do I need to change to get the range names to be deleted?

datasheet = ActiveSheet.Name
CurBook = Application.ActiveWorkbook.Name

For i = 3 To 48
rangename = Workbooks(CurBook).Worksheets(datasheet).Range("b" &

i).Value
sht = Workbooks(CurBook).Worksheets(datasheet).Range("a" & i).Value
CurBook.Worksheet(sht).Names(rangename).Delete
Next i

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Deleting worksheet specific range names

Thanks. That did it!

"Peter T" wrote:

Assuming 'rangename' is returning a valid Worksheet level name for 'sht' try
changing

CurBook.Worksheet(sht).Names(rangename).Delete


Workbooks(CurBook).WorksheetS(sht).Names(rangename ).Delete

Rather than Workbooks(CurBook) you could set a reference to the workbook.

Regards,
Peter T

"Barb Reinhardt" wrote in message
...
I have a datasheet with a list of worksheet range names that I want to
delete. The sheet name is in column A and the range name is in column B.

I
have the following
code. What do I need to change to get the range names to be deleted?

datasheet = ActiveSheet.Name
CurBook = Application.ActiveWorkbook.Name

For i = 3 To 48
rangename = Workbooks(CurBook).Worksheets(datasheet).Range("b" &

i).Value
sht = Workbooks(CurBook).Worksheets(datasheet).Range("a" & i).Value
CurBook.Worksheet(sht).Names(rangename).Delete
Next i

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
Deleting invisible range names - how? Kevryl Excel Discussion (Misc queries) 3 June 2nd 10 06:27 AM
Defining worksheet specific range names Barb Reinhardt Excel Programming 2 January 17th 06 03:46 PM
deleting worksheets from names in a range Jenn Excel Discussion (Misc queries) 2 August 23rd 05 12:00 AM
Deleting range names CiaraG[_4_] Excel Programming 1 May 10th 04 04:39 PM
Deleting broken range names Ray Kanner[_2_] Excel Programming 1 February 17th 04 02:29 AM


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

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"