+ Reply to Thread
Results 1 to 8 of 8

VBA to transfer Excel data to an Access table

  1. #1
    Registered User
    Join Date
    10-17-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    VBA to transfer Excel data to an Access table

    Hi there,

    I input data into an excel spreadsheets every day and would like to automate a way to transfer the data to Access from Excel. (Since I'm working with different excel spreadsheets I'm wanting to avoid importing from Access)
    I have a worksheet that gathers the information into the same format as the Access database, but am lost on how to write a code to get it to export to Access. I've been researching this for awhile and feel like I may be missing something. I was trying to use this code http://www.exceltip.com/st/Export_da...Excel/425.html
    but was having trouble just connecting to the database.
    If it makes it easier, the data I need to transfer is always in the same cells.

    Thanks in advance for help!

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,864

    Re: VBA to transfer Excel data to an Access table

    Does it make sense for you to link the Excel Spreadsheet to the Access Database. This is a viable option. Any changes to the spreadsheet will automatically be updated in Access.

    No code required if you do it this way.

    alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    10-17-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA to transfer Excel data to an Access table

    The excel document is several worksheets that track the progress of a Lot# at a factory. There can be up to 4-5 different documents per day, but they are all going to the same table. (I wish we could do the whole process electronically, but that's a no go) Would linking 4-5 documents a day be feasible? And could that be turned into an automated process too?

    I wanted to do it from the excel side because I wanted to enter the data into my excel spreadsheet template, send the formatted data to access via a VBA and then save the excel workbook as a different file. (Each workbook is named "Lot #, Production Traceability" so there will be hundreds of these soon.)

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,864

    Re: VBA to transfer Excel data to an Access table

    I'm a little bit confused now. What is the purpose of putting the information into Access. Will all the spreadsheets that you want to transfer to Access each day be in separate tables or all in one table? Will they be in new tables or will you be appending existing tables.

    Alan

  5. #5
    Registered User
    Join Date
    10-17-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA to transfer Excel data to an Access table

    I'll be appending the data to an existing Table, which I can then use to create reports in conjunction with other tables in the same database. The data from each excel workbook is one line in an access table, that is slowly building on itself so that I can have a relational view of the data. (Which I can't have with hundreds of excel worksheets)

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,864

    Re: VBA to transfer Excel data to an Access table

    Ok. You will have to import the data into Access into a temp table and then run an append query to add the data to existing tables. Make sure to delete the temptable after the append query runs.

    Here is a link on some code for importing data from multiple spreadsheets to Access tables. You will probably have to amend it a bit for your exact situation, but it is a starting point.

    http://www.mrexcel.com/forum/showthr...dsheets+Access

    Alan

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA to transfer Excel data to an Access table

    You can import directly from Excel, but be careful as it gives your users access to your DB

    something like:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-13-2008
    Location
    Montreal
    MS-Off Ver
    Office XP
    Posts
    80

    Re: VBA to transfer Excel data to an Access table

    Here is the code I use for the exact same issue, You can place the code in a macro or before close or on open . You will need to reference DAO

    Please Login or Register  to view this content.
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1