Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleting a named range in VBA

Could anybody please tell me how to delete a named range in VBA please.

I have a named range called "AUDITOR" and i have a routine that add
data to the range(which is stored for A2:A6 (for example).
But obviously when i've added more data to the list i want then t
assign the name "AUDITOR" to include the newly added item.

Any help appreciated.

TI

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Deleting a named range in VBA

Jako,

You can delete a named range with code like the following.

ThisWorkbook.Names("TheName").Delete

However, if you just want to change the range to which the name
refers, you can use the Add method on the existing name, and this
will change the refers-to range. E.g.,

ThisWorkbook.Names.Add "TheName", Range("A1:A10")

In the above case, it doesn't matter that TheName already exists.
If so, it will be revised to refer to the new range.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Jako " wrote in message
...
Could anybody please tell me how to delete a named range in VBA

please.

I have a named range called "AUDITOR" and i have a routine that

adds
data to the range(which is stored for A2:A6 (for example).
But obviously when i've added more data to the list i want then

to
assign the name "AUDITOR" to include the newly added item.

Any help appreciated.

TIA


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Deleting a named range in VBA

Hi Chip

I have recently discovered a strange phenomenon,
which looks like a bug to me.
Tested in Excel 97, 2000, 2002 and 2003 with
the same disturbing result.

Assuming a *global* name "TheName", which
e.g. is the range "A1:A10" on sheet1.

On sheet2 make a *local* name "TheName"
(e.g. cells B1:B5) with Insert Name Define
and in "Names in workbook" (or similar) enter
sheet2!TheName

Now, if sheet2 is **active**, when

ThisWorkbook.Names("TheName").Delete

is executed, the *local* name on sheet2 is deleted,
while the global one remains!!

If any other sheet is active during execution, the *global*
name is deleted, while the local one remains (of course!)

It really looks like, it's necessary to check for similar named
local names on the active sheet, when you want to delete a global one!

--
Best Regards
LeoH

Followup to newsgroup only please.

"Chip Pearson" skrev i en meddelelse
...
Jako,

You can delete a named range with code like the following.

ThisWorkbook.Names("TheName").Delete

However, if you just want to change the range to which the name
refers, you can use the Add method on the existing name, and this
will change the refers-to range. E.g.,

ThisWorkbook.Names.Add "TheName", Range("A1:A10")

In the above case, it doesn't matter that TheName already exists.
If so, it will be revised to refer to the new range.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Deleting a named range in VBA

Hi Norman

Thanks for the pointer!
Nothing new under the sun, I guess.
(at least in this situation <g)

--
Regards
LeoH


"Norman Jones" skrev i en meddelelse
...
Hi Leo,

See this earlier discussion:

http://tinyurl.com/2bguw


---
Regards,
Norman



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
deleting multiple named ranges april Excel Discussion (Misc queries) 1 April 15th 08 07:03 PM
problem in deleting the named ranges Maya[_2_] Excel Worksheet Functions 1 June 28th 07 12:52 PM
Deleting Named Ranges Carl Excel Worksheet Functions 2 August 31st 06 07:16 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
Deleting many named ranges Tom Hayakawa Excel Worksheet Functions 2 March 28th 05 10:47 PM


All times are GMT +1. The time now is 09:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"