Export 2 queries to one excel file on 2 diff sheets

brianlb

Board Regular
Joined
May 12, 2009
Messages
83
Is it possible to epxport two different Access '03 queries to one excel file. Two sheets holding the data from the two different queries? So basically I have Query A and Query B. I want to Export Query A to excel file ABC, sheet1 and export Query B to excel file ABC, sheet2. I tried this with the macro builder but couldn't figure it out. thx
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
You can do this with a macro or vba it would be TransferSpreadsheet you are looking for, you would use 2 of them for each query if you use the separate query names in each Transfer it will place them on individual sheets. Sample code below:

Sub Export2Queries()
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Query1", "full location and workbook Name.xls", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Query2", "full location and workbook Name.xls", True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,125,000
Members
449,202
Latest member
Pertotal

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