ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting unused Defined Names in a workbook? (https://www.excelbanter.com/excel-programming/329323-deleting-unused-defined-names-workbook.html)

Mike Piazza

Deleting unused Defined Names in a workbook?
 
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


All times are GMT +1. The time now is 01:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com