Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Deleting invisible range names - how? | Excel Discussion (Misc queries) | |||
Defining worksheet specific range names | Excel Programming | |||
deleting worksheets from names in a range | Excel Discussion (Misc queries) | |||
Deleting range names | Excel Programming | |||
Deleting broken range names | Excel Programming |