Copy specific columns from multiple sheets into one workbook

  • I have 12 sheets which consist A-T columns in each sheet. I want to copy and combine only C and T columns from each sheets. I'm new to VBA, I've been trying for hours but still didn't work. This is the code I got from somewhere here in the forum, I'm trying to change the code but this only copy C and T from the very last sheet while the others just C without T. Can someone help me? Thanks in advance :)


    Sub Create_Summary()

    Application.DisplayAlerts = False
    On Error Resume Next

    Application.DisplayAlerts = True
    ' n = Application.Worksheets.Count

    Sheets("Summary").Move after:=Worksheets(Worksheets.Count)

    Dim sh As Worksheet
    For Each sh In ActiveWorkbook.Worksheets
    If sh.Name <> "Summary" Then
    Set col = Columns(Columns.Count).End(xlToLeft)
    Set col = Columns(Columns.Count).End(xlToLeft)
    sh.Range("C:C,T:T").Copy Destination:=Sheets("Summary").Range(col, col)
    End If

    Next sh

    End Sub

  • Re: Copy specific columns from multiple sheets into one workbook


    Please choose to edit your post, highlight all of your code, choose the # icon on the toolbar and re-save your post.


    Your code will then look like this.

    Code
    Sub Test()
    End Sub


    This is called using code tags and is how you should post all code to this board.

    Bruce :cool:

  • Re: Copy specific columns from multiple sheets into one workbook


    Also.. you have cross posted this query...


    http://stackoverflow.com/quest…-multiple-sheets-into-one


    Please read this to understand why I have even mentioned this:
    http://www.excelguru.ca/content.php?184



    btw.. a more efficient way (imo), would have been to put each sheets value into an array and use Application.Index to populate your Summary sheet with the required columns..

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!