Sub Macro1()
'
' Macro1 Macro
'
ActiveWorkbook.Names("Item_Types").Delete
'
End Sub
ONLY works if the "Item_Types" named range was already in there when the workbook opened.
I have a script that creates a named range with that name, but needs to delete it later (not the data in the named range, just the reference to it).
For whatever reason, it fails to delete the named range I created giving me this error:
"application defined or object defined error"
PLEASE NOTE, I am NOT trying to delete the data REFERENCED by the named range, I am trying to delete the reference TO the named range. I.e. the end result of this formula should change NOTHING on the workbook, but should simply remove the "Item_Types" line from the name manager.
This script shows how to delete a name:
Sub DeleteBadRefs()
Dim nm As Name
For Each nm In ActiveWorkbook.Names
If Instr(1, nm.RefersTo, "#REF!")>0 Then
'List the name before deleting
Debug.Print nm.Name & ": deleted"
nm.Delete
End If
Next nm
End Sub
But it deletes it based on what it references. I want to delete it based on what the name is.
Bookmarks