Deleting unused Defined Names in a workbook?

M

Mike Piazza

I am trying to write a macro to delete the unused defined names in a
workbook. I am looking for a way to test if the name is used in the workbook
somewhere and if it is a print area... I was hoping to come up with some sort
of if statement to accomplish this and put it below in the [New Code]
placeholder. Thanks for the help.

Sub DeleteNames()

'
' DeleteNames Macro
' Macro Written 5/12/2005 by MRP
'

Dim rng As Range
Dim ThisName As Name
Msg = "This Macro will delete all unused Defined Names in this workbook.
Are you sure you wish to proceed?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbYes Then

For Each ThisName In ActiveWorkbook.Names
[New Code]
ThisName.Delete
Next ThisName

End If

End Sub
 

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