phamvandunghp84
Thành viên thường trực




- Tham gia
- 5/3/20
- Bài viết
- 241
- Được thích
- 12
Khi mình muốn copy một vùng cố định sang dòng cuối của một sheet khác mình code như này thì đúng.
[A1:U4].Copy Destination:=Sheets("data").[A65000].End(xlUp).Offset(1, 0)
Bây giờ mình cần copy một vùng động mình viết code như này nhưng không chạy được. Xin hỏi phải viết như nào mới đúng?
[(Cells(3,i)): (Cells(lastRow,i+6))].Copy Destination:=Sheets("data").[A65000].End(xlUp).Offset(1, 0)
đây là code mình đang có, nhờ các bạn sửa giúp. Cảm ơn các bạn !
Sub chuyen_sang_cot()
Dim i As Integer
Dim j As Integer
Dim lastRow As Integer
Dim lastColumn As Integer
Dim ws As Worksheet
Sheets("sheet1").Activate
Set ws = ActiveSheet
'find last column of row
lastColumn = ws.Range("A2:ZZ2").End(xlToRight).Column
For i = 1 To lastColumn Step 7
lastRow = ws.Cells(ws.Rows.Count, "i").End(xlUp).Row
[(Cells(3,i)): (Cells(lastRow,i+6))].Copy Destination:=Sheets("cot").[A65000].End(xlUp).Offset(1, 0)
Next i
End Sub
[A1:U4].Copy Destination:=Sheets("data").[A65000].End(xlUp).Offset(1, 0)
Bây giờ mình cần copy một vùng động mình viết code như này nhưng không chạy được. Xin hỏi phải viết như nào mới đúng?
[(Cells(3,i)): (Cells(lastRow,i+6))].Copy Destination:=Sheets("data").[A65000].End(xlUp).Offset(1, 0)
đây là code mình đang có, nhờ các bạn sửa giúp. Cảm ơn các bạn !
Sub chuyen_sang_cot()
Dim i As Integer
Dim j As Integer
Dim lastRow As Integer
Dim lastColumn As Integer
Dim ws As Worksheet
Sheets("sheet1").Activate
Set ws = ActiveSheet
'find last column of row
lastColumn = ws.Range("A2:ZZ2").End(xlToRight).Column
For i = 1 To lastColumn Step 7
lastRow = ws.Cells(ws.Rows.Count, "i").End(xlUp).Row
[(Cells(3,i)): (Cells(lastRow,i+6))].Copy Destination:=Sheets("cot").[A65000].End(xlUp).Offset(1, 0)
Next i
End Sub