Delete Named Range if no longer valid

nigelk

Well-known Member
Joined
Aug 30, 2008
Messages
537
Hi all,

I have this code

Code:
  On Error Resume Next
    For Each Nm In ThisWorkbook.Names
        Nm.Delete
    Next Nm
    On Error GoTo 0

Is it possible to change it so that it only removes the names that evaluate to a Ref# error?

Thanks,Nigel
 
Wow neat. It lists only the range names that don't have ref errors. Tried unprotecting sheets. Still not helping. I got procedure in personal macro workbook. That shouldn't make a difference,should it? Dunno, I am at a loss here. Thanks again for your input.
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
That's your problem.

The reference is to ThisWorkbook.Names which will look at the workbook that contains the code (ie, Personal).
Change to Activeworkbook.Names and try again.

Denis
 
Upvote 0
You were right!! I changed it to activeworkbook and ran the code. It did not delete the names, but what it did do is it enabled edit and delete buttons in namesmanager. Is that how it is supposed to work? Everybody thank you very much. Where have you people been all my life? LOL
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,706
Members
452,939
Latest member
WCrawford

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