Delete ranged names

ShoYnn

Board Regular
Joined
Mar 20, 2019
Messages
60
Office Version
  1. 2016
Platform
  1. Windows
So I have an interesting one for you all.

I have a master workbook I made for a gradesheet and put it in the public folder. When a new class starts the instructor will make a new folder for that class and copy the master book into that folder. It is still in beta mode, so as the classes have been going on the instructors have been making requests and suggestions for changes to the gradebook. I typically make the changes to the master and tell the active ones to suffer until next round, unless jt is an actual bug, but this one time I made the changes only to the active class as sort of a pilot to see if the instructors likex the new way or old way better. At the end of the pilot they liked the new way better, so instead of recreating the changes in the master book I just copied the sheets from the active class to the master book and made sure all of the formulas were fixed so they didn't reference the active class book and all was well. The one thing I forgot to do was remove the named ranges that got copied over to the master book, so now in my master book I have multiple named ranges that have the same name, but one will be referencing the madter book which is good, and one will be referencing the active class book which is not good. I have since then tried to delete the named range doppelgangers that reference the active class book, but they are completely greyed out, and it doesn't matter if I have both gradebooks open and fully unlocked, I cannot seem to delete them. Does anyone know how to delete a named range that references a separate workbook? Thanks for any help you can provide!

P.S. I totally tried vba
Sub delete_names
ActiveWorkbook.Names("sheet name").Delete
End Sub
and this did not work, gives me a 1004 error.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hello,

You could test following

Code:
Sub DeleteNamedRanges()
Dim NRng As Name
For Each NRng In Names
    ActiveWorkbook.Names(NRng.Name).Delete
Next NRng
End Sub

Hope this will help
 
Upvote 0
A valiant effort, but no luck. That didn't even touch any of the named ranges. Thanks for the reply though!
 
Upvote 0
Strange ...

Just tested it out ... and it deleted all the named ranges ...

Do you still see all the names with Control F3 ...?
 
Upvote 0
Yeah, all of the ranges still exist, not a single one was deleted ?
 
Upvote 0
Well, some good news, after running that code a couple of times with no luck I went through and triple verified that all of the sheets were unlocked, I even made all of my behind-the-scenes hidden sheets visible again and verified they were unlocked, and after doing this I was able to delete the Named Ranges I needed to. Funny thing was that I tried this before, so maybe I missed one sheet when I went through before unlocking everything, or maybe running your code changed something, who knows. Good news is that the problem is resolved! Thanks for the help!
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,181
Members
452,615
Latest member
bogeys2birdies

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