smiley3141
Board Regular
- Joined
- Aug 13, 2010
- Messages
- 77
Hello, everyone.
I am trying to delete a named range and then delete the defined name also, so that my name manager is not full of old names. I recorded my actions while trying to delete a range called "Area2."
The code that was recorded was:
Sub Delete_Named_Range()
Application.Goto Reference:="Area2"
Selection.Delete Shift:=xlUp
ActiveWorkbook.Names("Area2").Delete
End Sub
Now each time I try to run this, the range is deleted correctly, but I get a "Runtime error '1004' Application defined or object-defined error." I imagine it has something to do with the range it refers to being deleted, but am not sure how to correct for this.
Does anyone have any ideas?
Thanks for your help.
I am trying to delete a named range and then delete the defined name also, so that my name manager is not full of old names. I recorded my actions while trying to delete a range called "Area2."
The code that was recorded was:
Sub Delete_Named_Range()
Application.Goto Reference:="Area2"
Selection.Delete Shift:=xlUp
ActiveWorkbook.Names("Area2").Delete
End Sub
Now each time I try to run this, the range is deleted correctly, but I get a "Runtime error '1004' Application defined or object-defined error." I imagine it has something to do with the range it refers to being deleted, but am not sure how to correct for this.
Does anyone have any ideas?
Thanks for your help.