2016-06-28 206 views
1
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 

繼續獲取粘貼特殊範圍類失敗的錯誤。這是失敗的原因是什麼,我如何糾正我的代碼。剪切和粘貼範圍vba

+1

我不認爲你可以粘貼只是用切值。 –

+0

好吧只是清除內容才能完成相同的任務。謝謝! – aggieman

回答

2

你不能從切割中粘貼特殊。用途:

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 
+1

嘿,歡迎來到1K! –