Results 1 to 34 of 34

Thread: [RESOLVED] Append 2 or more workbooks of multiple sheets into a single workbook

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2012
    Posts
    16

    Resolved [RESOLVED] Append 2 or more workbooks of multiple sheets into a single workbook

    Hi everybody,
    I have 6 excel workbooks each with 193 sheets. Format of all the workbooks is same with the same sheet names. I want to append the data of all the 6 workbooks into one workbook just like sheet1 of workbook1 would have the original data of sheet1 of workbook1 then in the very next empty available row paste the data of sheet1 of workbook2 then sheet1 of workbook3 and so on till sheet1 of workbook6, same for the sheet2 , sheet3....................sheet193.

    I wrote this code it is working but it does not paste by maintaining the sequence (Problem is it sometimes paste the sheet3 of workbook2 into the sheet1 of workbook1 but by desire it should paste the sheet1 of workbook2 into the sheet1 of workbook1)

    All six Workbook names are:
    HYD15.xls
    HYD16.xls
    HYD17.xls
    HYD18.xls
    HYD19.xls
    HYD20.xls


    I am appending HYD16.xls and HYD17.xls into HYD15.xls (kindly help)
    Code:
    Sub append_test()
        
        For Index = 1 To 193
        
        Windows("HYD16.xls").Activate
        Worksheets(ActiveSheet.Index).Activate
        lastCol = ActiveSheet.Range("a6").End(xlToRight).Column
        lastRow = ActiveSheet.Cells(65536, lastCol).End(xlUp).Row
        ActiveSheet.Range("a6:" & _
        ActiveSheet.Cells(lastRow, lastCol).Address).Select
        Selection.Copy
        Windows("HYD15.xls").Activate
        Worksheets(ActiveSheet.Index).Activate
        NextRow = Range("A65536").End(xlUp).Row + 1
        Cells(NextRow, 1).Select
        ActiveSheet.Paste
        Worksheets(ActiveSheet.Index + 1).Activate
        
        Next Index
        For Index = 1 To 193
        
        Windows("HYD16.xls").Activate
        Worksheets(ActiveSheet.Index).Activate
        lastCol = ActiveSheet.Range("a6").End(xlToRight).Column
        lastRow = ActiveSheet.Cells(65536, lastCol).End(xlUp).Row
        ActiveSheet.Range("a6:" & _
        ActiveSheet.Cells(lastRow, lastCol).Address).Select
        Selection.Copy
        Windows("HYD15.xls").Activate
        Worksheets(ActiveSheet.Index).Activate
        NextRow = Range("A65536").End(xlUp).Row + 1
        Cells(NextRow, 1).Select
        ActiveSheet.Paste
        Worksheets(ActiveSheet.Index + 1).Activate
        
        Next Index
    
    End Sub
    Last edited by Hack; Jul 17th, 2012 at 11:22 AM. Reason: Added Code Tags

Posting Permissions

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



Click Here to Expand Forum to Full Width