Results 1 to 10 of 15

Thread: Excel to Excel Data transfer without opening any of the files(source or target)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member Transformer's Avatar
    Join Date
    Mar 2012
    Posts
    91
    Rep Power
    13

    Excel to Excel Data transfer without opening any of the files(source or target)

    If you want to transfer data from one excel file to another then you can use the following procedure.
    code:
    Code:
    Sub TransferData(strInputFileFullName As String, strOutPutFileFullName As String, strInputSheetName As String)
        
        Dim adoConnection   As New ADODB.Connection
        Dim adoRcdSource    As New ADODB.Recordset
       
        adoConnection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " & strOutPutFileFullName & ";Extended Properties=""Excel 8.0;HDR=YES"";"
        adoRcdSource.Open "Select * into [" & strInputSheetName & "] From [" & strInputSheetName & "] IN '" & strInputFileFullName & "'[Excel 8.0;HDR=YES;]", adoConnection
           
    End Sub

    Code:
    call TransferData("E:\source.xls","E:\Destination.xls","shtData")
    If target workbook is not available in the destination drive then it will create it automatically and transfer the data.
    eg. if in above example if Destination.xls is not available then it will create it with the sheet "shtData"


    Regards,
    Transformer
    Last edited by Transformer; 03-24-2012 at 12:06 AM.

Similar Threads

  1. Replies: 4
    Last Post: 06-09-2013, 01:43 AM
  2. Macro to copy data from a set of excel files
    By Sreejesh Menon in forum Excel Help
    Replies: 5
    Last Post: 11-15-2012, 11:17 AM
  3. Macro for Opening files and copy the contents of the File
    By ravichandavar in forum Excel Help
    Replies: 16
    Last Post: 08-15-2012, 09:17 PM
  4. Replies: 1
    Last Post: 06-26-2012, 08:17 PM
  5. Collate Data from csv files to excel sheet
    By dhiraj.ch185 in forum Excel Help
    Replies: 16
    Last Post: 03-06-2012, 07:37 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
  •