Delete All Names - Even Invalid "#REF" Names

B

Brian B.

FYI: The following code will delete all names in a workbook, including
those with a "#REF" error:

Sub Delete_Names()

Dim NameX As Name
On Error GoTo Nxt
For Each NameX In Names
ActiveWorkbook.Names(NameX.Name).Delete
Nxt:
Next NameX

End Sub

Adding the "On Error GoTo" will allow the code to also delete invalid
names too. I couldn't find this anywhere so I though I'd post it ...

-Brian
 
P

Peter T

To delete all names simply -

Dim nm as Name
for each nm in Activeworkbook.Names
nm.delete
Next

I can't think of anything that would raise an error doing this and require
some sort of error handler.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top