Copy multiple range from one sheet to another

  • Hi,


    I've been trying to copy multiple cells from sheet 1 to sheet 3. But every time that I will add a cell on the range it is giving me an error message "That Command cannot be used on multiple selections."
    There are also other cell that I want to copy and paste it on a specific cell in sheet3
    for example
    Sheet1: b4 and b6 I need to paste it in sheet3 cell is E4 and B4


    so the B4 in sheet 1 should be pasted in sheet3 E4 and b6 should be pasted in B4.



  • Try this. Add as many ranges as required. Change references as required.

    Code
    Sub AAAA()
    Dim cArr, i As Long, sh3 As Worksheet
    Set sh3 = Sheets("Sheet3")
    cArr = Array("D10:D12", "D15", "D25", "D32:D33") '<-----Add ranges as required
    For i = LBound(cArr) To UBound(cArr)
    Range(cArr(i)).Copy sh3.Cells(Rows.Count, 10).End(xlUp).Offset(1)
    Next i
    End Sub


    BTW, this works also



    Code
    Sub BBBB()
    Range("D10:D12,D15,D22,D25,D32:D33").Copy '<----- Add ranges as required
    Sheets("Sheet3").Cells(Rows.Count, 9).End(xlUp).Offset(1).PasteSpecial Paste:=xlValues
    End Sub



    Google about "selecting" in excel. You should stay away from it as much as possible, which is just about 100 % of the time.

  • BTW, this works also


    Code
    Sub BBBB()
    Range("D10:D12,D15,D22,D25,D32:D33").Copy '<----- Add ranges as required
    Sheets("Sheet3").Cells(Rows.Count, 9).End(xlUp).Offset(1).PasteSpecial Paste:=xlValues
    End Sub


    Google about "selecting" in excel. You should stay away from it as much as possible, which is just about 100 % of the time.

  • Code
    Sub This_Maybe()
    Dim rngArr
    rngArr = Array([D10], [D11], [D12], [D15], [D22], [D25], [D32], [D33], [D38], [D39], _
    [D40], [D41], [D42], [D47], [D48], [D49], [D50], [D53], [D55], [D57], [D63], [G3])
    Sheets("Sheet3").Cells(Rows.Count, 9).End(xlUp).Offset(1).Resize(, UBound(rngArr) + 1) = rngArr
    End Sub
  • Code
    Sub This_Maybe()
    Dim rngArr
    rngArr = Array([D10], [D11], [D12], [D15], [D22], [D25], [D32], [D33], [D38], [D39], _
    [D40], [D41], [D42], [D47], [D48], [D49], [D50], [D53], [D55], [D57], [D63], [G3])
    Sheets("Sheet3").Cells(Rows.Count, 9).End(xlUp).Offset(1).Resize(, UBound(rngArr) + 1) = rngArr
    End Sub



    I'm currently not infront of my work computer right now. be there in 15mins. i'll try this one out. I'll update you what happened. thanks :)

  • Code
    Sub This_Maybe()
    Dim rngArr
    rngArr = Array([D10], [D11], [D12], [D15], [D22], [D25], [D32], [D33], [D38], [D39], _
    [D40], [D41], [D42], [D47], [D48], [D49], [D50], [D53], [D55], [D57], [D63], [G3])
    Sheets("Sheet3").Cells(Rows.Count, 9).End(xlUp).Offset(1).Resize(, UBound(rngArr) + 1) = rngArr
    End Sub


    Hi,
    This works perfectly. one last question sir. Example is I want to copy b4 in sheet one together with all the cells i have and then paste it on sheet 3 which is in E and then right after that the D10 will be pasted in I. I mean is there a way to skip 3-4 cells?

  • Hi,
    This works perfectly. one last question sir. Example is I want to copy b4 in sheet one together with all the cells i have and then paste it on sheet 3 which is in E and then right after that the D10 will be pasted in I. I mean is there a way to skip 3-4 cells?


    Oh after I deleted the data in sheet3 to try it again. the code doesn't seem to work. :(

  • Which sheet was showing when you ran the code the 2nd time? The sheet with all the cells to be copied has to be the active (showing on your desktop) sheet.
    If, for instance you copy from sheet1 to sheet3, you have to have sheet 1 as active sheet.
    If you want to run it from anywhere, let us know.

Participate now!

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