我似乎遇到一个问题,让我的For Each
循环到...循环... Excel用"运行时错误' 1004':应用程序向我大喊大叫 - 定义或对象定义的错误"
Sub killingme()
Dim i As Integer, o As Integer
i = 2
o = 2
For Each r In Worksheets("Stats").Rows
If r.Range(Cells(i, 5)).Value = 9386 And r.Range(Cells(i, 6)) = 3486 Then
r.EntireRow.Cut
Worksheets("Sheet2").Rows(o).PasteSpecial (xlPasteValues)
o = o + 1
Stop
End If
i = i + 1
Next
End Sub
这个特殊的工作表有大约58k行,我需要循环并移动到不同的工作表。我一直在寻找超过2个小时,并没有找到解决方案。任何帮助将不胜感激。
答案 0 :(得分:2)
你能试试吗?
Sub killingme()
Dim i As Integer, o As Integer
i = 2
o = 2
For Each r In Worksheets("Stats").Rows
If Cells(r.Row, 5).Value = 9386 And Cells(r.Row, 6) = 3486 Then
r.EntireRow.Copy
Sheets("Sheet2").Rows(o & ":" & o).PasteSpecial (xlPasteValues)
r.EntireRow.Delete
o = o + 1
Stop
End If
i = i + 1
Next
End Sub