excel access macro

  • Thread starter Thread starter David Susseles
  • Start date Start date
D

David Susseles

Hello,

I am looking to learn how to build a macro / procedure to copy data in excel
and paste into an ms acess table.

any help would be appreciated.

Thanks.
 
David Susseles said:
I am looking to learn how to build a macro / procedure to copy data in excel
and paste into an ms acess table.

Wrong metal model <g>. Think 'update data in my Jet database table
using data in my Excel workbook'. Here's some sample code:

INSERT INTO
[Database=C:\MyJetDB.mdb.].MyTable
(MyTextCol)
SELECT
MyExcelCol AS MyTextCol
FROM
[Excel 8.0;HDR=YES;Database=C:\MyJetDB.xls.].[MyExcelTable]
;

You will need to find a suitable 'container' to execute the query e.g.
a stored query in the database, MS Query sql window in Excel, ADO in
code, etc. The above will work for any Jet connection e.g. to an
arbitary or non-existent workbook. If you are using a connection to
either the .mdb or the .xls, you can omit the connection string from
the sql text.

You need to ensure the Excel column is 'seen' by Jet as the correct
data type. For details, see:

http://www.dicks-blog.com/excel/2004/06/external_data_m.html

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top