Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Names not deleted until book closed

After deleting a query, and deleting its name from the name list, I
can't recreate a query with the same name without closing the workbook.
Here is a sample subroutine that illustrates the problem:

Option Explicit

Sub testA()
Dim qt As QueryTable
Dim nameEntry As Name

If Sheets(1).QueryTables.Count = 0 Then
Set qt = Sheets(1).QueryTables.Add _
("URL; http://www.cnn.com", Range("A1"))
qt.Name = "FirstQueryName"
qt.Refresh
Else
Sheets(1).QueryTables(1).Delete
For Each nameEntry In Sheets(1).Names
nameEntry.Delete
Next nameEntry
End If
End Sub


After executing this subroutine the first time, a query with the name
"FirstQueryName" is created. Upon the second execution, the query is
deleted. Then, after the third execution, the query is recreated, but
now the name is "FirstQueryName_1", even though the name has been
deleted from the name list! What am I missing?

This problem does NOT occur if I close and re-open the workbook between
the second and third invocations of the subroutine.

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
HYPERLINK() FOR A SPECIFIC CELL IN A CLOSED WORK BOOK & SHORTCUT FARAZ QURESHI Excel Discussion (Misc queries) 0 March 27th 08 06:49 AM
Fetching Comments from a closed work book [email protected] Excel Discussion (Misc queries) 1 March 13th 08 03:05 PM
Using Closed Workbook as Data Book DarnTootn Excel Discussion (Misc queries) 5 March 13th 07 09:51 PM
Copy Worksheet from closed book. Saurjusa Excel Programming 2 November 10th 05 05:49 PM
Range names being deleted and altered Todd Huttenstine[_2_] Excel Programming 3 November 30th 03 09:18 AM


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