PC Review


Reply
Thread Tools Rate Thread

Deleting worksheet specific range names

 
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      31st Oct 2006
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 With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      31st Oct 2006
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 With Quote
 
Peter T
Guest
Posts: n/a
 
      31st Oct 2006
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" <(E-Mail Removed)> wrote in message
news:146773EF-8527-4D23-BBC3-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      1st Nov 2006
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" <(E-Mail Removed)> wrote in message
> news:146773EF-8527-4D23-BBC3-(E-Mail Removed)...
> > 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 With Quote
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      1st Nov 2006
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 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
Consolidate by range names which represent worksheet tab names Wally Microsoft Excel Misc 4 14th Jul 2010 11:13 PM
Defining worksheet specific range names =?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?= Microsoft Excel Programming 2 17th Jan 2006 03:46 PM
Defining non worksheet specific names... Steve Microsoft Excel Worksheet Functions 0 29th Jun 2005 05:30 AM
copy range on every worksheet (diff names) to a master worksheet (to be created) Bernie Microsoft Excel Programming 2 22nd Sep 2004 03:30 PM
copy range on every worksheet (diff names) to a master worksheet (to be created) Bernie Microsoft Excel Programming 0 22nd Sep 2004 03:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:08 PM.