Query table name persists after deletion

Glory

Well-known Member
Joined
Mar 16, 2011
Messages
640
I'm trying to write some code to make a querytable. The problem is that, after the first table is deleted, when the second table is added, the name of the second table has a "_1" appended to the end.

I've tried deleting all the names on the worksheet, but that doesn't help. Any ideas?
 
I am not familiar with the use of connections in the "Object" sense. Someone else here may have some info on that. But in any case, I would think you will still have to be aware of if you are generating a bunch of "Connections" no longer used.

That of course you can observe them in the "Menu, Data, Connections" box that will display them.

Hope that all is of use.

Chuck
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
The code above (used to delete multiple connections) is referring to the connections as an object. Perhaps leaving the connection object not deleted, is linking to your Query table name object also, and may be why it is putting _1 on the end of the next query.

Try using the code above to delete all connections in between queries and see if the Query table name stops adding _1 to the next one.

Worth a try to see anyway.
 
Upvote 0
Tried it out. The delete method is not a property of the connection object for anything earlier than 2007. Thanks anyway.

Anybody else got any ideas?
 
Upvote 0
I wound up realizing that I didn't actually need my querytables to be named a certain specific way to extract the data from them. The ADO just looks at the ranges to get what it needs.

Instead of worrying about making sure they always kept exactly the same name, I settled for adding in the date, hour, minue and second of creation each time a new table is created. That way the name appears exactly the way I originally intended. There's never any chance of conflict with the old name, this way.
 
Upvote 0

Forum statistics

Threads
1,224,563
Messages
6,179,527
Members
452,923
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top