![]() |
![]() |
|
|||||||
| 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: Feb 2002
Location: Longmont, CO
Posts: 279
|
Is there a simple line of code that can remove all named ranges in a worksheet? How about all the named ranges in an entire workbook?
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Not quite sure what you mean, if you mean remove the data from the named ranges use this:
If you mean to remove the names from the ranges, use this:
These will work for the whole workbook, not individual sheets HTH |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Longmont, CO
Posts: 279
|
I will give this a try, thanks.
What I am specifically referring to is the "Names" that you can define using Insert/Name/Define - each of these refers to a group of cells. I refresh data daily from an external source, and what's been happening is that during the course of the month, each time I've refreshed, it's created a new Named Range. I simply want to remove these Names from the worksheets. |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Longmont, CO
Posts: 279
|
I tried this, (Example #2) and it does everything I want it to...but it also destroys my print areas. Is there any way to get this to work without blowing away the Print Areas?
Thanks! |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Nope, there's no way to preserve your print setup.
However, you can try this code. It creates an array and stores your printarea for each page, deletes the names, then resets all of the print areas. Give it a try because I haven't really tested it:
HTH |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Longmont, CO
Posts: 279
|
MyPrintArea(i) = Sheets(i).PageSetup.PrintArea
THis particular line of code gives me a Run Time Error 13 'Type Mismatch'. |
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Damn, you've probably got Charts inserted there as well. If that's the case, use this code:
HTH |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|