Deleting all Range names Except the Print_Area\Print_Titles

Gary_E

Board Regular
Joined
Feb 18, 2002
Messages
108
Trying to develop a "simple" code which deletes all of the Range Names in a Workbook without deleting the Print_Area\Print_Titles -

For example - in a workbook - I have the following ranges
Name: Refers to:
ABC =Sheet1!$F$21:$F$22
Sheet1!Print_Area =Sheet1!$C$1:$EG$91
Sheet1!Print_Titles =Sheet1!$A:$B,Sheet1!$1:$10

Here's what I've been able to pull together so far - It's a modification of
code from the The Excel Logic Page email: AaronBlood@ hotmail.com

Sub Play()
'Delete all ranges
For Each WBname In ActiveWorkbook.Names
If Not WBname Like "*" & "!Print_Area" And _
Not WBname Like "*" & "!!Print_Titles" Then
WBname.Delete
End If
Next
End Sub

The problem is it's reading the Refers to: data - not the Name Data - so it deletes every thing - I've tried all sorts of ways (1600 VBA CD, Walkenback's 2002 Power progragming, etc...) - Just doesn't seem to want to work
:oops:
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
This worked for me...Xl2000/XP


Code:
Sub Play()
Dim WBname As Name
'Delete all ranges
For Each WBname In ActiveWorkbook.Names
    If Not WBname.Name Like "*!Print_Area" And _
        Not WBname.Name Like "*!Print_Titles" Then
        WBname.Delete
    End If
Next

End Sub
 
Upvote 0
Re: Deleting all Range names Except the Print_Area\Print_Tit

Ivan :

Perfect !!!!!!!!!!!!!!!
(y)
 
Upvote 0

Forum statistics

Threads
1,215,970
Messages
6,127,991
Members
449,414
Latest member
sameri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top