Thread: code break
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave B[_3_] Dave B[_3_] is offline
external usenet poster
 
Posts: 25
Default code break

I have some code which tests for a condition and deletes unwanted rows:

For i = 2 To intLastRow

strCellText = ActiveCell.Text
intLocInStr = InStr(1, strCellText, "sample text", vbTextCompare)

If intLocInStr 0 Then
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.EntireRow.Delete
intLocInStr = 0
End If

strCellText = ""

Next i

Sometimes, after the ActiveCell.EntireRow.Delete line, the code breaks as if
I had pressed ctrl-Break. I get the message "Code execution has been
interrupted" with options to End, Debug, etc.

I don't have breakpoints or anything. Has anyone ever had this problem or
know why my code keeps breaking? (It's pretty annoying to have to sit there
and keep pressing C ... for Continue.)