none
Merge rows in a single excel sheet RRS feed

  • Question

  • I have an excel workbook(A) and its copy (B). Both contain one sheet only.

    In A, Rows 1-15 are filled. In B Rows 16-30 are filled. 

    How can I perform an automated merge of A and B files without using manual copy paste ? i.e copy rows 16-30 from B file to A file. The merged file will now contain all 30 rows filled.

    Please help.


    • Edited by Sahajth Thursday, February 5, 2015 6:01 PM More clarification of requirement
    • Moved by George123345 Friday, February 6, 2015 8:16 AM
    Thursday, February 5, 2015 5:44 PM

Answers

  • Hi,

    If you want to copy data from one workbook to another workbook data, the following code you can refer to:

    Sub DopyExcelData()

        Dim wkbk As Workbook

        Set wkbk = Workbooks.Open("D:\test2.xlsx")  'D:\test2.xlsx is my another excel workbook

         wkbk.Activate

        Sheets("Sheet1").Activate

            Range("A1:C15").Select

            Selection.Copy

           wkbk.Close False

           Range("A16").Select

        ActiveSheet.Paste

        MsgBox "OK"

      

      

    End Sub

    Hope this will help you

    Best Regards

    Lan


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by L.HlModerator Sunday, February 15, 2015 10:17 AM
    Tuesday, February 10, 2015 4:27 AM
    Moderator

All replies

  • Hi,

    This is the forum to discuss questions and feedback for Microsoft Excel, I'll move your question to the MSDN forum for Excel

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    George Zhao
    TechNet Community Support


    It's recommended to download and install Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office programs.
    Friday, February 6, 2015 8:15 AM
  • Hi,

    If you want to copy data from one workbook to another workbook data, the following code you can refer to:

    Sub DopyExcelData()

        Dim wkbk As Workbook

        Set wkbk = Workbooks.Open("D:\test2.xlsx")  'D:\test2.xlsx is my another excel workbook

         wkbk.Activate

        Sheets("Sheet1").Activate

            Range("A1:C15").Select

            Selection.Copy

           wkbk.Close False

           Range("A16").Select

        ActiveSheet.Paste

        MsgBox "OK"

      

      

    End Sub

    Hope this will help you

    Best Regards

    Lan


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by L.HlModerator Sunday, February 15, 2015 10:17 AM
    Tuesday, February 10, 2015 4:27 AM
    Moderator