vba to delete named ranges returning errors

cjcass

Well-known Member
Joined
Oct 27, 2011
Messages
679
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I have the code below that successfully deletes all named ranges that are displaying #REF!
I tried adapting it to delete all named ranges that are displaying #NAME? by simply changing the #REF! to #NAME? in the code but alas it didn't work. Any thoughts on how this can be achieved?
Any help much appreciated.
VBA Code:
For Each NR In ActiveWorkbook.Names
   If InStr(NR.Value, "#REF!") Then NR.Delete
   Next
 
Whoa ! that is a whole different story.
Those range names beginning with _xlfn are normally hidden. Did you unhide them ?
They seem to have something to do with backward compatibility.
Some posts ask about whether the workbook has been opened in in an older version but I just ran an unhide names on a new MS 365 workbook used to look at a question on this Forum that I know used a number of new formulas and it is full of "_xfln" #NAME entries.

Since Excel is creating these hidden entries I suggest leaving them alone.
When I tried to delete them, I got a 1004 error indicating it didn't like trying to access names starting with underscore.
That error might be new because I seem to recall having deleted them in the past to see what would happen and I think Excel just recreated them (but don't quote me on that)
PS: the x & y at the end are variables used in a Let function

View attachment 90679
Ok, understood - I should probably leave them be!
Yes, I unhid them.
Thanks again for your time and help with this, much appreciated.
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,214,839
Messages
6,121,892
Members
449,058
Latest member
Guy Boot

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top