从 Excel 自动加载到 Access
Automatic load into Access from Excel
请查看下面的代码,此时它从范围 "A1: G30000" 加载数据。我想更改此代码,以便加载 A1:D30000 和 F1:G30000 范围内的数据,即从上传中排除列 F 中的数据。
strFile = Dir(strPath & "*.xlsx")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
strTable, strPathFile, blnHasFieldNames = False, _
"Data!A1:G30000,"
要么使用:
"Data!A1:D30000;Data!F1:G30000"
或:
"Data!A1:D30000,Data!F1:G30000"
或打开 Excel 并定义覆盖此复合范围的 命名范围 :
=Data!$A:$D000,Data!$F:$G000
然后引用您在代码中分配此命名范围的名称。
请查看下面的代码,此时它从范围 "A1: G30000" 加载数据。我想更改此代码,以便加载 A1:D30000 和 F1:G30000 范围内的数据,即从上传中排除列 F 中的数据。
strFile = Dir(strPath & "*.xlsx")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
strTable, strPathFile, blnHasFieldNames = False, _
"Data!A1:G30000,"
要么使用:
"Data!A1:D30000;Data!F1:G30000"
或:
"Data!A1:D30000,Data!F1:G30000"
或打开 Excel 并定义覆盖此复合范围的 命名范围 :
=Data!$A:$D000,Data!$F:$G000
然后引用您在代码中分配此命名范围的名称。