我的代码出了点问题我无法弄明白。
我想将column C
从workbook 1
的{{1}}复制到worksheet wsCopyFrom_OFP
column D
workbook 2
中worksheet wsCopyTo
具有值的行将被复制
LastRow_OFP = wsCopyFrom_OFP.Cells(wsCopyFrom_OFP.Rows.Count, "C").End(xlUp).Row
For i = 4 To LastRow_OFP
wsCopyFrom_OFP.Cells(i, 3).Copy
erow = wsCopyTo.Cells(wsCopyTo.Rows.Count, 1).End(xlUp).Offset(1, 0).Row
wsCopyFrom_OFP.Paste Destination:=Worksheets(wsCopyTo).Cells(erow, 1)
Next i
非常感谢
答案 0 :(得分:0)
尝试使用以下代码
LastRow_OFP = wsCopyFrom_OFP.Cells(wsCopyFrom_OFP.Rows.Count, "C").End(xlUp).Row
For i = 4 To LastRow_OFP
wsCopyFrom_OFP.Cells(i, 3).Copy wsCopyTo.Range("A" & wsCopyTo.Range("A" & Rows.Count).End(xlUp).Row + 1)
Next i
编辑#1
尝试使用以下代码
LastRow_OFP = wsCopyFrom_OFP.Cells(wsCopyFrom_OFP.Rows.Count, "C").End(xlUp).Row
For i = 4 To LastRow_OFP
wsCopyFrom_OFP.Range("C" & i & ":C" & i + 3).Copy
wsCopyTo.Range("A" & wsCopyTo.Range("A" & Rows.Count).End(xlUp).Row + 1).PasteSpecial (xlPasteValues)
Next i