Exporting to Excel

  • Thread starter Thread starter Sarah at DaVita
  • Start date Start date
S

Sarah at DaVita

Hi. I have a massive table that I need to get to excel. It has data by
center number. I would like to export each center to a different tab in an
excel workbook. The center numbers are not always constant and in the
current table there are about 100 different ones so will most likely have
more then one workbook. Is there a way I can export each to a tab without
writting a specific query for each center? I thought perhaps a function of
some type but have no idea how to write it. Can someone help with this?
 
Hi Sarah
To export data to Excel the easiest way is to use the TransferSpreadsheet
function in VBA.
To do that you need a saved query definition. since you are going to need
about 100 of these
you need a routine to create, save and erase the query definition inside of
a loop.
Each iteration will refer to a different center number as in strSQL
= "Select * for " & [Center Number] &" = X".
X will have been set to a valid center number. The transferspreadsheet
function will
each time refer to and save a different spreadsheet the name of which will
have an incremented
tag on the end built like "c:\MyFile" & Cstr(X) & ".xls".

Regards

Kevin
 
Thank you so much. The site you sent me is great. I should be able to do
what I need to now.
 
Back
Top