Results 1 to 4 of 4
  1. #1
    BrockWade is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    63

    Problem with Excel Import Run-time error '2391'

    I am having trouble getting the following code to load data from my Excel file "Book.xlsx" into my table called "ExcelDataBook":

    Sub btnExcelImport_Click()
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "ExcelDataBook", _
    "C:\Users\dacampb1\Desktop\Book.xlsx", , "Sheet1!A1:B12000"
    End Sub



    The Excel file only has one sheet "Sheet1' and has only 10,504 rows but this can vary so I set it in the code for 12,000 rows. The sheet has only two columns "A" and "B" with the first row of the two columns labeled "Store" and "Amount" and my tabel has only two fields "Store" and "Amount".

    My error reads:

    Run-time error '2391': Field 'F1' doesn't exist in the destination table 'ExcelDataBook.'

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    I think you are missing the "Has Label" between the file name and range.

    Sub btnExcelImport_Click()
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "ExcelDataBook", _
    "C:\Users\dacampb1\Desktop\Book.xlsx", True , "Sheet1!A1:B12000"
    End Sub

  3. #3
    BrockWade is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    63
    I decided to just link the Excel files and all is running fine except when I run a query on the file I get about 1,041 blank rows before my data is displayed in the query's datasheet view or any report based upon this query... the data seems good but why the leading blank rows? The data in the linked Excel sheet does not look like this and another Excel file's query looks fine and they seem set up indentically! Thoughts?

  4. #4
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    It is hard to debug without your excel file.
    The only thing I can suggest is to delete all the columns and rows that has no data (highlight them and delete). Sometimes if a cell is being formated or touched, it will consider that is a data cell by MS Access/MS Excel.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error 2391
    By drunkenneo in forum Programming
    Replies: 1
    Last Post: 07-03-2013, 03:05 AM
  2. Import Excel spreadsheet Search key not found error
    By synses in forum Import/Export Data
    Replies: 1
    Last Post: 07-01-2013, 11:05 AM
  3. Problem with Excel import
    By itsmemike in forum Import/Export Data
    Replies: 3
    Last Post: 04-04-2011, 09:25 PM
  4. Run-time error on import (Split DB)
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 03-15-2011, 06:43 AM
  5. Excel import error
    By limez0r in forum Programming
    Replies: 1
    Last Post: 11-15-2010, 08:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums