VBA import,export, and run query

ExcelTheCell

Board Regular
Joined
Nov 14, 2010
Messages
158
Hi all,
Well this would be great if it could be possible and if someone could have the answer.
Lets say i have 3query's in database named Test1.

First Step (export)
Query1 and Query2 i would like to export in my documents and save them like excel table but changing the name to Query1T and Query2T.

Second Step (Import)
I would like to import above tables Query1t and Query2T to another database named Test2(that can also be found in my documents) and after close that database

Thirth Step(link and run)
I would like to import as link Query1T and Query2T to Test1 database and after that run Query3 from Test1 Database..Can you help me people?

Tnx,
 

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.
Take a look at the different Actions you can do via a Macro. You can run queries, import, and export. The Macro builder gives you all the arguments and help on what should be in each one.

If you name a Macro "AutoExec", it will run automatically upon opening the database (as long as Macros are enabled).

Also, if you need to make it more dynamic, on the Macro Toolbar there is an option to "Convert Macros to Visual Basic". So, if you create a Macro for one scenario, then convert the code to Visual Basic, you will have most of the code you need, and you can edit it to generalize it to suit your needs.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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