Results 1 to 5 of 5
  1. #1
    mazemi is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jun 2016
    Posts
    4

    Question importing excel data to access via VBA


    Hi Dears.I want to import some separated columns from an excel file via this codeoCmd.TransferSpreadsheet acImport, 10, "MyTable", "MyExcelFile", True, "A:G, K:K" In fact i don't want to import whole data from my excel file. But it doesn't work. Please help me to set the "Range" parameter in the "TransferSpreadsheet" command.Tanks in advance!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I haven't used the range parameter. I'd probably link to the file, then run an append query that selected the desired fields.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    you can't have multiple ranges - you'll need to use "A:K"

    Alternatively reorder your excel file so columns H:J are outside the range you require or have another worksheet to put your 'data for export' into one block

  4. #4
    mazemi is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jun 2016
    Posts
    4
    Tanks Paul and Ajax for your response.As you mentioned It is not possible to use multiple ranges. So I will try to reorder my excel columns and import it in this way. But I have so many excel files for reordering and fixing and this is a challenge!And I also try to use append query too.Tank again.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No problem. The link/append query method would let you leave the Excel files as-is.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Importing excel into access data model
    By aisling21 in forum Access
    Replies: 2
    Last Post: 05-12-2015, 07:03 AM
  2. Importing Excel Data Tables into Access
    By Itch in forum Programming
    Replies: 5
    Last Post: 09-08-2012, 11:27 AM
  3. Importing Data from Excel to Access
    By dkatorza in forum Import/Export Data
    Replies: 3
    Last Post: 11-05-2011, 09:17 AM
  4. Replies: 2
    Last Post: 04-22-2010, 10:40 AM
  5. iMPORTING DATA FROM EXCEL TO ACCESS
    By Rameez in forum Import/Export Data
    Replies: 7
    Last Post: 06-16-2009, 12:05 PM

Tags for this Thread

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