[英]cut and paste range vba
For j = 1 To numrows - 1
erow = Cells(Rows.count, 10 + j).End(xlUp).Row
totalMins = Cells(erow, 10 + j)
MsgBox (totalMins)
Range(Cells(erow, 10 + j), Cells(erow, 10 + j).End(xlUp)).Cut
Cells(20, 20).PasteSpecial xlPasteValues
Next
不斷收到pastespecialrange類失敗錯誤。 這是什么原因導致失敗,以及如何糾正我的代碼。
您不能從剪切中粘貼特殊內容。 采用:
For j = 1 To numrows - 1
erow = Cells(Rows.count, 10 + j).End(xlUp).Row
totalMins = Cells(erow, 10 + j)
MsgBox (totalMins)
Range(Cells(erow, 10 + j), Cells(erow, 10 + j).End(xlUp)).Cut Cells(20, 20)
Next
或者更好:
For j = 1 To numrows - 1
erow = Cells(Rows.count, 10 + j).End(xlUp).Row
totalMins = Cells(erow, 10 + j)
MsgBox (totalMins)
Cells(20, 20) =Range(Cells(erow, 10 + j), Cells(erow, 10 + j).End(xlUp))
Range(Cells(erow, 10 + j), Cells(erow, 10 + j).End(xlUp)).ClearContents
Next
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.