I want to delete all global named ranges in a workbook. I have this code:
Dim xName As Name
For Each xName In Application.ActiveWorkbook.Names
If InStr(xName.Name, "!") = 0 Then xName.Delete
Next
Even when I change the code to delete ALL named ranges, I still get the same error.
Dim xName As Name
For Each xName In Application.ActiveWorkbook.Names
xName.Delete
Next
When I run it, only the first Named Range is deleted and then it throws a 400 error. It doesn't move on to the next one.
Is there some sort of add-on or setting that I'm missing? This code seems pretty straight-forward, but I can't get it to work.
If InStr(xName.Name, "!") = 0 Then xName.Deleteand once there type?xName.Name, xname.RefersToin Immediate Window and press return .