Results 1 to 25 of 25

Export Data from a closed workbook

Threaded View

  1. #6
    Registered User
    Join Date
    10-14-2015
    Location
    Brisbane
    MS-Off Ver
    2010
    Posts
    12

    Arrow Re: Export Data from a closed workbook

    Hi:

    Find the attached.

    You will have to add the following references in your VBA Editor:
    • Microsoft ActiveX Data Objects 6.1 Library
    Sub test()
    
    Dim rsData As ADODB.Recordset
    
    rsFile$ = ThisWorkbook.Path & "\" & Sheet1.Range("C1") & ".xlsx"
    strConn$ = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                        "Data Source=" & rsFile & ";" & _
                        "Extended Properties=""Excel 12.0;HDR=Yes"";"
     
    rsSQL$ = "SELECT * FROM [Sheet1$]"
    Set rsData = New ADODB.Recordset
    
    rsData.Open rsSQL, strConn, , adOpenUnspecified, adLockUnspecified
    Sheet1.Range("E4").CopyFromRecordset rsData
    
    End Sub
    Note: I am assuming that you will be storing all your files in the same folder as your macro file.

    Thanks
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Export filtered data into different closed workbook as new worksheet
    By Griffin29 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-16-2014, 06:24 AM
  2. Replies: 0
    Last Post: 03-27-2014, 12:38 PM
  3. Export Excel data into closed workbook
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-09-2013, 12:15 AM
  4. Export data from closed workbook to active workbook with ADO connection
    By Naresh27 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-09-2013, 01:08 PM
  5. Replies: 12
    Last Post: 07-03-2013, 01:35 PM
  6. How to export data to a closed Workbook
    By newbie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2005, 05:05 AM
  7. [SOLVED] Export data to a closed workbook
    By Luis in forum Excel General
    Replies: 0
    Last Post: 05-21-2005, 09:06 AM

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