Forum Discussion

Mohamed Hasan Marie's avatar
Mohamed Hasan Marie
Copper Contributor
Mar 07, 2018
Solved

Transfer data from one workbook to another

Hey guys. Could you please support me to get VBA code for copying data from Worbook X to first empty rowe in workbook Y
  • Jamil's avatar
    Mar 07, 2018

    Hello Mohamed,

     

    Here is the piece of code. This may not be the best effective way, but something that can do the job for you. 

    ' you can amend the A1:Z100 range to whatever is your actual data range

     

    You should put this code in a module of workbook from which you want the data to be copied from.

    it will copy from Sheet1 of thisworkbook into the path and file name and sheet Sheettopasteto

     

     

    Sub CopyfromThisworkbookToANother()
    Workbooks.Open ("C:\Documents\ExcelFiletoPasteDataTo.xlsx") ' you can amend this path and file name to you actual path and file name
    ThisWorkbook.Sheets("Sheet1").Range("A1:Z100").Copy Workbooks("ExcelFiletoPasteDataTo.xlsx").Sheets("Sheettopasteto").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)

    End Sub

     

Resources