我有一些代码无缘无故停止执行,也没有产生错误。会不会是内存问题?它正在操作的工作表大约有 1600 行,其中包含大量格式和条件格式,并且代码在插入一行后停止。这是它停止的代码片段:
With wsBudget
TotalColumn = .Range("TotalColumn").Column
FormulaColumn = .Range("FormulaColumn").Column
If .Cells(lRow, 1).Interior.Color <> 14408946 Then 'OK to insert
cell.EntireRow.Copy
cell.Resize(RowCount, 1).EntireRow.Insert 'It stops after stepping into this line
.Cells(cell.Row - RowCount, 1).EntireRow.ClearContents
.Cells(cell.Row - RowCount - 1, FormulaColumn).Resize(RowCount + 1, 1).FillDown
.Cells(cell.Row - RowCount - 1, TotalColumn).Resize(RowCount + 1, 1).FillDown
.Cells(cell.Row - RowCount - 1, 1).Resize(RowCount, 1).Interior.Color = RGB(255, 255, 255) 'OK to insert or delete
Else
MsgBox "You must select a cell within a table before inserting a row."
Exit Sub
End If
End With