我的代码在前 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)