Insert Data from Excel into Access

前端 未结 5 1268
不思量自难忘°
不思量自难忘° 2020-12-18 11:04

I\'ve made some code to insert data from an excel table in to an access database - my code is as follow:

    Sub AddData()

Dim Cn As ADODB.Connection

Set C         


        
5条回答
  •  盖世英雄少女心
    2020-12-18 11:48

    xlFilepath = Application.ThisWorkbook.FullName
    Sql = "INSERT INTO tblSales " & _
    
    "SELECT * FROM [Excel 12.0 Macro;HDR=YES;DATABASE=" & xlFilepath & "].[datasheet$A1:AK10011] "
    
    cnn.Execute Sql
    

    Warning in your Datasheet Table The first 8 rows. Assuming theres a Heading (HDR=YES) the next 6 rows should contain a dummy data to define your columns equivalent to your access table column definition.

提交回复
热议问题