Reputation: 955
I'm using the below code to copy paste a specific range of cells to another sheet..
sht.Cells(Rows.Count, 1).End(xlUp).Offset(1) = comp.Range("B" & i).Value
sht.Cells(Rows.Count, 2).End(xlUp).Offset(0) = comp.Range("C" & i).Value
sht.Cells(Rows.Count, 3).End(xlUp).Offset(0) = comp.Range("D" & i).Value
sht.Cells(Rows.Count, 4).End(xlUp).Offset(0) = comp.Range("E" & i).Value
sht.Cells(Rows.Count, 5).End(xlUp).Offset(0) = comp.Range("F" & i).Value
sht.Cells(Rows.Count, 6).End(xlUp).Offset(0) = comp.Range("G" & i).Value
sht.Cells(Rows.Count, 7).End(xlUp).Offset(0) = comp.Range("H" & i).Value
sht.Cells(Rows.Count, 8).End(xlUp).Offset(0) = comp.Range("I" & i).Value
sht.Cells(Rows.Count, 9).End(xlUp).Offset(0) = comp.Range("J" & i).Value
sht.Cells(Rows.Count, 10).End(xlUp).Offset(0) = comp.Range("K" & i).Value
sht.Cells(Rows.Count, 11).End(xlUp).Offset(0) = comp.Range("L" & i).Value
Is there anyway to do it in a single line?
Thank you in advance :)
Upvotes: 0
Views: 39
Reputation:
Try,
sht.Cells(Rows.Count, 1).End(xlUp).Offset(1).resize(1, 11) = _
comp.Range("B" & i & ":" & "L" & i).Value
Upvotes: 1