我有一个带有一些数据的excel文件,我需要使用VBA将所有数据导入MS Access,然后对其运行查询,最后在报告中显示数据。 如何实现这一目标?
答案 0 :(得分:2)
确保Microsoft Excel数据采用列表格式:每列在第一行中都有一个标签,并包含类似的事实,列表中没有空行或列。
Close the Excel workbook that contains the data you want to use in Microsoft Access.
In Access, open the database where you want to copy the Excel data.
On the Access File menu, point to Get External Data, and then click Import.
In the Import dialog box, click Microsoft Excel in the Files of type box.
In the Look in list, locate the file you want to import, and then double-click the file.
Follow the directions in the Import Spreadsheet Wizard.
由于
答案 1 :(得分:0)
使用docmd.transterspreadsheet,如下所示:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml,tblName, impPath, False, impSheet
where tblName is table to add data to
impPath is path and file name of excel workbook to import from
false = no field names in import area (true =field name included in import area)
sheet = sheet name and range ie "sheet!b5:j15"