![](/img/trans.png)
[英]Run Time Error 1004 You can't paste this here because the Copy area and paste area aren't the same size
[英]Run Time Error 1004 You Can't Paste This Here
我的代碼在前 800 次迭代中有效(它在一個包含大約 4,000 個文件的文件夾中運行),現在它拋出了這個錯誤
“運行時錯誤'1004':您無法在此處粘貼此內容,因為復制區域和粘貼區域的大小不同。僅選擇粘貼區域中的一個單元格或相同大小的區域,然后再次嘗試粘貼.”
這是我的代碼:(僅與錯誤相關的部分)
With sht1
With .Cells(1, 1).CurrentRegion
With .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count)
If CBool(Application.Subtotal(103, .Columns(1))) Then
.Cells.Copy Destination:=.Cells(.Rows.Count + 1, 1)
End If
.AutoFilter
.Cells(1, 1).Resize(.Rows.Count, 1).EntireRow.Delete
End With
End With
End With
錯誤發生在這一行:
.Cells.Copy Destination:=.Cells(.Rows.Count + 1, 1)
原來問題是 excel 最多只允許 1,048,576 行,我試圖粘貼在它下面。
為了解決這些限制並加速我的代碼,我現在使用 PowerQuery 來導入和過濾數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.