I am trying to unname a range if cells if it exists. The code below finds the range with the right name, but explodes at nm.Delete line, without any explanation. How can I fix/debug it?
Thanks!
Function unefineRange(strRgeName As String)
Dim nm As Name
For Each nm In ThisWorkbook.Names
If nm.Name = strRgeName Then
nm.Delete
End If
Next nm
End Function
I just ran this in Excel 2003 and it ran fine:
I created two named ranges, Fred and Wilma, and ran this (module 1) in the Visual Basic editor. Deleted “Wilma” with no problems.