Macro to copy specific column rows from one workbook sheet to another

  • here is what i have:

    Code
    Sub Button1_Click()
    With Workbooks("childsheet.xlsm").ActiveSheet
        .Range("A3", .Cells(.Rows.Count, "A").End(xlUp)).Copy Destination:=Workbooks("parentsheet.xlsm").Worksheets("Account").Range("A3")
        .Range("B3", .Cells(.Rows.Count, "B").End(xlUp)).Copy Destination:=Workbooks("parentsheet.xlsm").Worksheets("Account").Range("B3")
    End With
    End Sub



    what i want is something like this:

    Code
    Sub Button1_Click()
    With Workbooks("childsheet.xlsm").ActiveSheet
        .Range("A3:A14", .Cells(.Rows.Count, "A").End(xlUp)).Copy Destination:=Workbooks("parentsheet.xlsm").Worksheets("Account").Range("A3:A14")
        .Range("B3:B15", .Cells(.Rows.Count, "B").End(xlUp)).Copy Destination:=Workbooks("parentsheet.xlsm").Worksheets("Account").Range("B3:B15")
    End With
    End Sub


    It should copy all cells (even empty ones), right now it copies the whole column (A and B) but i only want to copy specific rows (A3: A14)
    can anybody help?

  • If you want to copy hard-coded ranges just use

    Code
    Sub Button1_Click()
    With ActiveSheet
        .Range("A3:A14").Copy Destination:=Workbooks("parentsheet.xlsm").Worksheets("Account").Range("A3:A14")
        .Range("B3:B15").Copy Destination:=Workbooks("parentsheet.xlsm").Worksheets("Account").Range("B3:B15")
    End With
    End Sub

Participate now!

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