Skip to main content

Posts

Showing posts from June, 2012

Excel Macro – Copy Sheets to Another File

Can use this Macro to copy data in multiple sheets into a unified single sheet in another excel file. Open the source file. Open a blank workbook and save it with some name eg: ‘target’. Keep both source and target files open. In the macro, replace ‘source’ with name of source file. Replace ‘target’ with name of the blank file. Sub CopyLoop()         Dim Ws As Worksheet         Dim i As Integer         Dim K As Integer         i = 2  ‘ first row of copyselection         ' Loop through all of the worksheets in the active workbook.         Windows("source").Activate         For Each Ws In Worksheets         K = K + 1          Ws .Range("A2:AL116").Copy         Windows("target").Activate         Cells(i, 2).Select         ActiveSheet.Paste         Range(Cells(i, 1),Cells(i+116,1)) = Ws .Name         Windows("source").Activate         i = i + 116  ‘last row of copy selection       '  If K &g