Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ksh ksh is offline
external usenet poster
 
Posts: 16
Default Named range prob using VB to move wksheet to an existing wkbook

Is there a way to delete all named ranges in a workbook? I have tried

ActiveWorkbook.Names ("*").Delete

but the wildcard does not work in this code.

The background is that I have to replace worksheets each month in workbooks
for 9 countries. I have a macro set up that deletes the prior month
worksheets from each country file and then opens the various workbooks with
the current month's info and copies the appropriate worksheets into the
country's file. The problem is that the worksheets I am copying in
apparently have a named range and I receive the message regarding the fact
that the name already exists on the destination worksheet which causes my
macro to fail.

I set up the original country workbooks myself and they do not require any
named ranges. I think that it is a leftover name from the company that
prepares the monthly reports, but by the time I get it, it doesn't have any
formulas.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Named range prob using VB to move wksheet to an existing wkbook



Is there a way to delete all named ranges in a workbook?


Sub blahblaah()

With ActiveWorkbook

For x = .Names.Count To 1 Step -1

.Names(x).Delete

Next

End With

End Sub



Regards



GB


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Named range prob using VB to move wksheet to an existing wkbook

Sub deleteNames()
Dim nme As Name

For Each nme In ActiveWorkbook.Names
If nme.Name Like "*_FilterDatabase" Or _
nme.Name Like "*Print_Area" Or _
nme.Name Like "*Print_Titles" Or _
nme.Name Like "*wvu.*" Or _
nme.Name Like "*wrn.*" Or _
nme.Name Like "*!Criteria" Then
Else
nme.Delete
End If
Next nme

End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"ksh" wrote in message
...
Is there a way to delete all named ranges in a workbook? I have tried

ActiveWorkbook.Names ("*").Delete

but the wildcard does not work in this code.

The background is that I have to replace worksheets each month in
workbooks
for 9 countries. I have a macro set up that deletes the prior month
worksheets from each country file and then opens the various workbooks
with
the current month's info and copies the appropriate worksheets into the
country's file. The problem is that the worksheets I am copying in
apparently have a named range and I receive the message regarding the fact
that the name already exists on the destination worksheet which causes my
macro to fail.

I set up the original country workbooks myself and they do not require any
named ranges. I think that it is a leftover name from the company that
prepares the monthly reports, but by the time I get it, it doesn't have
any
formulas.



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
Update Cell in WKBook 1 From WkBook 2 pattlee Excel Discussion (Misc queries) 2 May 25th 08 01:27 PM
After Copy and Paste, Add to an Existing Named Range Aria[_2_] Excel Programming 4 March 8th 07 12:53 AM
How do i link an entire source wksheet to a dest' wksheet tazzer Excel Worksheet Functions 2 August 5th 06 07:28 AM
How to link to a single wksheet in a wkbook that has comments RedRobyn Excel Discussion (Misc queries) 1 June 27th 06 07:40 PM
Copy range from one wksheet to another malefeous Excel Programming 0 August 8th 05 09:24 PM


All times are GMT +1. The time now is 07:01 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"