Deleting named ranges in the name manager fails to make the name available for re-use

GuitarMaker81

New Member
Joined
Sep 8, 2011
Messages
3
Hello all. I'm using Excel 2010 to complete an application that I started developing in Excel 2003, which uses named lists extensively. The migration happened without much incident, however, while making some tweaks and using tables where I'd left off, I discovered a peculiar problem. Say I create a table in the normal way, Ctrl-T, and then name the table "Frustration"; then I decide to make an adjustment to the table, or delete it entirely from the workbook by converting it to a normal range. If I then create a new table and attempt to give it the name "Frustration", I get the error message, "The name entered already exists. Enter a unique name." Even though scouring the Name Manager on the Formulas tab indicates that the name was deleted, I am still prevented from using the name again. Where else might one access range names that are currently in use? Better yet, how would one simply delete a name that matches a given string from Application.Names? Thanks to the community for providing such an insightful resource.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi Guy's and welcome to the forum.

Give this code a run and see if it helps out. It will delete all named ranges, so you may need to tweek it or test it in a copy of your workbook, don't test on real workbook.

Sub DeleteNames()
Dim nm As Name

On Error Resume Next
For Each nm In ActiveWorkbook.Names
nm.Delete
Next
On Error GoTo 0


End Sub
 
Upvote 0
Thank you Trevor. This worked, but is there a way to manually delete the names from the "Activeworkbook.names" that the code references? I have two problems that I need to work around:

- We have too many print ranges and other defined ranges to make using this solution viable.

- We have a mix of excel 2010 and 2003 users. If 2010 users use this macro, they will have to do some additional steps to get the macro to go away (http://www.mrexcel.com/forum/showthread.php?t=518757&highlight=modules+deleted). The 2003 users have tremendous fear of the Macro warning when they open books, so the files must be macro free. Books are also saved as xls at this point to save the '03 users the time to wait for excel to convert the xlsx.

Brett
 
Upvote 0
Manual way would be via the Formula tab and also look at print areas to see if additional names have been used.
 
Upvote 0
That is what prompted this problem, there are no names listed in name manager. For example, I have a blank workbook that opens up when excel starts. It has one tab, no modification from a blank workbook except column width changes and a footer that says my name and the file path. If I need more tabs, I'll right click the one tab and copy it as a new tab.

Excel will then inform me that "A formula or sheet you want to move contains the name'_Fill', which already exists on the destination worksheet ......" and then proceed to rename the name in my newly copied sheet.

I can delete the footers, select the whole sheet and delete the cells, remove the print areas, check the name box & name manager (which will show nothing), but when I copy, I still get the error. Your script works perfectly.

I can even make a cell reference to the name and it bombs out (#REF), rightfully so, because when I ask it to "show calculation steps" it tells me the path/file/cell that it is looking to. If I search for any parts of the file path throughout the workbook, it comes up with nothing. For this name to be stored in this book, shouldn't I be able to see this path stored somewhere? Whether name manager (it isn't) or VB?

I really appreciate your help.

Brett
 
Upvote 0
Mike's December, 31 2011 post on this other string provided the work around I needed.

First I run that script in a newly created tab in the "infected" workbook without saving the file. After running the script I can delete all the old hidden names which are now revealed in Name Manager. Before saving the file, I delete all traces of the macro, and when I save, Excel has no "memory" of the macro.

Brett
 
Upvote 0

Forum statistics

Threads
1,216,732
Messages
6,132,409
Members
449,726
Latest member
Skittlebeanz

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