PC Review


Reply
Thread Tools Rate Thread

Delete all named ranges in a workbook

 
 
bevanward@gmail.com
Guest
Posts: n/a
 
      7th Nov 2006
Hi All

I've obviously missing something here and would appreciate any help.
I've seen a few similar threads but they haven't helped ....

I have an excel 97 workbook with a series of named ranges and would
like to delete them all. I'm suring the code ...

Sub a()


Worksheets(1).Select

For i = 1 To Worksheets.Count

Worksheets(i).Select

For n = 1 To ActiveSheet.Names.Count
strNAME = ActiveSheet.Names(n).Name
ActiveSheet.Names(n).Delete
Next n

n = 1
Worksheets(i).Select

Next i



End Sub

.... however when I run this code I keep getting error 9 from the
subscript being out of range.

I'm sure I'm making a simple mistake...

Thanks in advance

Cheers
Bevan

 
Reply With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      7th Nov 2006
See:

http://groups.google.com/group/micro...c78b6698d1f38b
--
Gary's Student


"(E-Mail Removed)" wrote:

> Hi All
>
> I've obviously missing something here and would appreciate any help.
> I've seen a few similar threads but they haven't helped ....
>
> I have an excel 97 workbook with a series of named ranges and would
> like to delete them all. I'm suring the code ...
>
> Sub a()
>
>
> Worksheets(1).Select
>
> For i = 1 To Worksheets.Count
>
> Worksheets(i).Select
>
> For n = 1 To ActiveSheet.Names.Count
> strNAME = ActiveSheet.Names(n).Name
> ActiveSheet.Names(n).Delete
> Next n
>
> n = 1
> Worksheets(i).Select
>
> Next i
>
>
>
> End Sub
>
> .... however when I run this code I keep getting error 9 from the
> subscript being out of range.
>
> I'm sure I'm making a simple mistake...
>
> Thanks in advance
>
> Cheers
> Bevan
>
>

 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      7th Nov 2006
Names belongs to the workbook not the worksheet...
For n = 1 To ActiveWorkbook.Names.Count
ActiveWorkbook.Names(n).Delete
Next n
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


<(E-Mail Removed)>
wrote in message
Hi All
I've obviously missing something here and would appreciate any help.
I've seen a few similar threads but they haven't helped ....
I have an excel 97 workbook with a series of named ranges and would
like to delete them all. I'm suring the code ...

Sub a()
Worksheets(1).Select

For i = 1 To Worksheets.Count

Worksheets(i).Select

For n = 1 To ActiveSheet.Names.Count
strNAME = ActiveSheet.Names(n).Name
ActiveSheet.Names(n).Delete
Next n

n = 1
Worksheets(i).Select
Next i



End Sub

.... however when I run this code I keep getting error 9 from the
subscript being out of range.

I'm sure I'm making a simple mistake...

Thanks in advance

Cheers
Bevan

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      7th Nov 2006
Be careful, there are some system ranges which you might want to avoid
deleting

The ones I know of are of the format

*_FilterDatabase
*Print_Area
*Print_Titles
*wvu.*
*wrn.*
*!Criteria


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jim Cone" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Names belongs to the workbook not the worksheet...
> For n = 1 To ActiveWorkbook.Names.Count
> ActiveWorkbook.Names(n).Delete
> Next n
> --
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
>
>
> <(E-Mail Removed)>
> wrote in message
> Hi All
> I've obviously missing something here and would appreciate any help.
> I've seen a few similar threads but they haven't helped ....
> I have an excel 97 workbook with a series of named ranges and would
> like to delete them all. I'm suring the code ...
>
> Sub a()
> Worksheets(1).Select
>
> For i = 1 To Worksheets.Count
>
> Worksheets(i).Select
>
> For n = 1 To ActiveSheet.Names.Count
> strNAME = ActiveSheet.Names(n).Name
> ActiveSheet.Names(n).Delete
> Next n
>
> n = 1
> Worksheets(i).Select
> Next i
>
>
>
> End Sub
>
> ... however when I run this code I keep getting error 9 from the
> subscript being out of range.
>
> I'm sure I'm making a simple mistake...
>
> Thanks in advance
>
> Cheers
> Bevan
>



 
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
How can I delete all named ranges in a workbook or worksheet? AZSteve Microsoft Excel Programming 5 21st Oct 2009 06:48 PM
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... christian_spaceman Microsoft Excel Programming 3 24th Dec 2007 01:15 PM
macro to delete all named ranges in a workbook en masse? =?Utf-8?B?RGF2ZSBG?= Microsoft Excel Misc 1 3rd Nov 2006 09:17 PM
Phantom named ranges in a workbook? Dave O Microsoft Excel Misc 3 26th Sep 2006 05:26 PM
Checking for named ranges in a workbook loopoo Microsoft Excel Programming 2 22nd Nov 2005 05:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:54 PM.