Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Range Names in Excel

Status
Not open for further replies.

ramnewbietoaccess

Programmer
Nov 4, 2002
52
US
I have a worksheet that has 122 ranges named. I need to delete all of them and rename them. I know how to delete one but i was wondering since there so many is there a faster way to delete it rather than "Name" highlight it and then delete one at a time
 
Here you go...

Sub Delete_All_RangeNames()
num = ActiveWorkbook.Names.Count
For i = 1 To num
ActiveWorkbook.Names(1).Delete
Next i
End Sub

Regards, Dale Watson
 
Hi,

copy this code into a MODULE and run
Code:
for each n in names
  n.delete
next


Skip,
[sub]
[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue][/sub]
 


If you use Dale's solution, be sure to correct the index
Code:
   ActiveWorkbook.Names([b][red]i[/red][/b]).Delete


Skip,
[sub]
[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue][/sub]
 
I tried both suggestions and when i run the module it highlights the n and says variable not defined. i should add that i am using 2000 if that matters. any suggestion?
 
You have options explicit...
Code:
Dim n
for each n in names
  n.delete
next


Skip,
[sub]
[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue][/sub]
 
If you didn't want to use VBA then the simplest way is to use an old Lotus keystroke command that works in Excel but which doesn't have an equivalent without VBA.

Tools > Options > Transition
Select the Lotus 1-2-3 Help option

Thereafter:

/RNR

Will clear all of your names including those set by Excel such as
Print_Area.

But watch out. There's no, "Are you sure!" And there's no Undo capability. But if this is what you want, it sure beats doing it one at a time.

Regards
Ken..............

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
---------------- Click here to help the tsunami victims ----------------

 
oh my duh i didnt define the variable thanks that really saved me a day of monotony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top