![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 246
|
i have a simple macro that creates Names. however, when a worksheet(s) that contains references to a Name is deleted, the list of Names in the Define Names box still contains a listing of that name. However, the reference to that Name is #ref'd (e.g., '#REF!$A$1).
since users of this excel file will be creating/deleting many worksheets, there will be a long list of un-used, un-referenced, 'dead' Names. #1 - is there a maximum # of Names allowed? i don't want users to exceed this limit and crash the tool. #2 - even if #1 is not a concern, managing a long list of Names (of which a vast majority will be junk) is not a good thing. can someone offer up a short macro that checks for bogus Names and deletes them from the Names list? thanks for your attention. mach3 |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Allentown, PA
Posts: 2,510
|
1. Limited only by the available memory on the PC.
__________________
~Anne Troy |
|
|
|
|
|
#3 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Hi Mac
Run this code on open or close etc Code:
Sub DeleteREFnames() Dim nmRef As Name For Each nmRef In ActiveWorkbook.Names If Left(nmRef.RefersTo, 5) = "=#REF" Then nmRef.Delete Next End Sub |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Posts: 246
|
thanks. i just added the macro to an existing macro and works fine.
mach3 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|