• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2499
  • Last Modified:

How import certain Excel columns into table in Access

I need to find a way to import certain columns of an Excel file into an Access table.

Here are the specifics:

1) The Excel file will always be in a specific folder on the user's desktop named "Import Files".
2) There will be only one Excel file in the folder.
3) The data to import will always be in "Sheet1"
4) This may change but for example I need columns A, B, C, D, F, and G
5) The first column will hold the primary key field.
6) The name of the table the data is to import into is "tblImports"

The is one more challenge to this but I'll ask in it a separate topic once this topic has been resolved.
0
SteveL13
Asked:
SteveL13
  • 4
  • 3
1 Solution
 
Dale FyeCommented:
I generally use the TransferSpreadsheet method to import all of the fields into a staging table (tblStageExcelData), then I use a query to append only the fields I need into my destination table (tblImports).  This allows me to use the built in conversion functions to ensure that the data that ends up in my destination table is in the correct format.
0
 
SteveL13Author Commented:
I must be doing something wrong.  What is wrong with this?

DoCmd.TransferSpreadsheet acImport, 3, "tblTempImport", "C:\ImportFiles\ImportFile.xlsx", True

(I'm using Access 2010)
0
 
Dale FyeCommented:
I don't see '3' being an option for the spreadsheet type argument.  Try:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "tblTempImport", "C:\ImportFiles\ImportFile.xlsx", True
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
SteveL13Author Commented:
That did work.  But a question...  will acSpreadsheetTypeExcel12 work for Access 2007 as well as 2010?
0
 
Dale FyeCommented:
Yes.
0
 
SteveL13Author Commented:
Thank you very much.
0
 
Dale FyeCommented:
welcome.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now