Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Deleting all Range Names except Print_Area?

4 views
Skip to first unread message

Dave Peterson

unread,
May 16, 2005, 7:56:35 PM5/16/05
to
Option Explicit
Sub DeleteNames()
Dim ThisName As Name
For Each ThisName In ActiveWorkbook.Names
If LCase(ThisName.Name) Like LCase("*!Print_Area") Then
'do nothing
Else
ThisName.Delete
End If
Next ThisName

End Sub

But I'd be careful. There are other names that excel uses, too.

You may want to get a copy of Jan Karel Pieterse's (with
Charles Williams and Matthew Henson) Name Manager:

You can find it at:
NameManager.Zip from http://www.oaltd.co.uk/mvp

You may see some names that you want to add.

* is a wild card
! because print_area is a worksheet level name. The name could be
sheet1!print_area.
lcase() just because text comparisons make me nervous.

Nodak wrote:
>
> I am trying to delete all Named Ranges Except "Print_Area" is there a way to
> accomplish this? the code below deletes "Print_Area"..
>
> Sub DeleteNames()
> Dim ThisName As Name
> For Each ThisName In ActiveWorkbook.Names
> If ThisName <> "Print_Area" Then ThisName.Delete
> Next ThisName
>
> End Sub

--

Dave Peterson

0 new messages