Results 1 to 6 of 6
  1. #1
    mahmud1180 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    20

    Using cells function while importing data from excel


    Is there any way to use cells function instead of a range like ( A1: AC100)? I need to use numbers as I want to iterate the process. I want to make different tables from a single spread sheet. Any suggestions?

    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Futures" & i, "C:\users\Mahmud\Desktop\Project\Futures.xlsb" , True, "Sheet1!Cells(4,1),Cells(100,100)"

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    I dont think that will work. You can only use SHEET1. (no range)
    BUT, you can attach the xl sheet as a table, then build an import query that only imports what you need. Similar to cell range.

  3. #3
    mahmud1180 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    20
    Range works only if I put Sheet1!"A1:AC100"

    The problem with making query after importing is that it will change the name of the fileds. It is difficult to iterate the name of every fields.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Options that I see:
    1) You use VBA to loop through the Excel cells.
    2) You could save the data in different worksheets and import each worksheet to a separate table.
    3) Save the data as CSV files and import each CSV file into a separate table.
    4) You could save the whole spreadsheet as a CSV file and use VBA to parse the data into different tables on-the-fly. (I do this)


    You might check out Ken Snell's site
    Ken's ACCESS Examples and Information for Working With EXCEL Workbook Files
    http://www.accessmvp.com/kdsnell/EXCEL_MainPage.htm

  5. #5
    mahmud1180 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    20
    I have tried to make separate sheet but now I am stuck with changing the sheet name dynamically. I tried also using a fixed name of the sheet and deleting the sheet before the next iteration begins. Still it does not work . Any idea? Thanks

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The only thing I can suggest is using VBA to loop through the Excel cells.
    A lot of code, but you can control everything that happens - which workbook is opened, what cells are read, which table(s) the data should go in...

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

Similar Threads

  1. Blank cells are Importing
    By Sumanth.Ganjam in forum Access
    Replies: 3
    Last Post: 01-08-2014, 08:04 PM
  2. Replies: 0
    Last Post: 03-12-2012, 03:57 PM
  3. Replies: 6
    Last Post: 11-05-2011, 09:01 AM
  4. Replies: 1
    Last Post: 08-19-2010, 01:08 PM
  5. VBA Opening Excel File and Placing Data in Cells
    By BobTHG in forum Programming
    Replies: 0
    Last Post: 01-13-2008, 03:01 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