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
不断收到pastespecial range class失败错误。这是什么原因导致失败,以及如何纠正我的代码。
您不能从剪切中粘贴特殊内容。使用:
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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句