ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   renaming a query (https://www.excelbanter.com/excel-programming/383609-renaming-query.html)

Candyman

renaming a query
 
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?

Tom Ogilvy

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?



All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com