View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default renaming a query

Run this code

Sub MakeNamesvisible()
Dim nme as Name
for each nme in ActiveWorkbook.Names
nme.Visible = True
Next
End sub

Now look at the names collection and you will see there is a defined name
related to each query table. I suspect the "already exists" name is found
there still as well. Perhaps deleting it will allow you to rename your
query.

--
Regards,
Tom Ogilvy


"Candyman" wrote:

I had to change the SQL on an existing query, but the columns came back in
the wrong sequence. So then I deleted the query range (got the warning I was
detelting a query) and built the new query table.

Now too match up with my VBA I want to rename the query table
"ExternalData_1". I receive the message : "A query with this name already
exists on this sheet". Yet when I loop through all the sheets/queryTables. I
do not see the "ExternalData_1" table listed. How do I get Excel to allow me
to rename my new ExternalData_1 query?