我的循环在最后一行之前打破了几千行。在添加行时循环到最后一行
比方说,最后一行是高达12000,它的循环,直到9800
For i = 2 To lastrow
If ws.Cells(i, 2).Value = "4" Then
Rows(i).Insert
Range("E" & i).Value = ws.Cells(i + 1, 5)
i = i + 1
lastrow = lastrow + 1
End If
Next i
'lastrow'的数据类型是什么?您的工作表中有多少行可用? –
你是什么意思的“打破”是一个错误,只是停止,随机文本... – sous2817
@ sous2817它不给我任何错误,只是停止。我有11000行,然后我通过插入多行来添加更多的行,为什么我使用i = i + 1,所以我的lastrow加起来是12000.所以它停在9800.不知道为什么 – user3713336