剪切和粘贴范围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
继续得到pastespecial范围类失败的错误。 这是失败的原因是什么,我怎样才能纠正我的代码。
你不能从切口粘贴特殊的。 使用:
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