I have a macro that formats data for me. I've attached a spreadsheet with it in and the data it formats but for some reason it just keeps on running and won't stop once finished. I have to hit ESC twice to get out of it.
Dim lRow As Long
Dim lLastTime As Double
Dim iTimeCount, iLoopCounter As Integer
lLastTime = Cells(2, 3)
iTimeCount = 1
For lRow = 3 To 350
If Cells(lRow, 3) <> lLastTime Then
For iLoopCounter = iTimeCount To 2
Rows(lRow).Insert Shift:=xlDown
Cells(lRow, 3) = Cells(lRow - 1, 3)
lRow = lRow + 1
Next iLoopCounter
lLastTime = Cells(lRow, 3)
iTimeCount = 1
Else
iTimeCount = iTimeCount + 1
If iTimeCount > 3 Then
Rows(lRow).Delete Shift:=xlUp
lRow = lRow - 1
End If
End If
Next lRow
End Sub
The problem is with the last part of the macro where it starts "Dim lRow As Long" and I have put the line "For lRow = 3 To 350" in the macro which I thought should make it stop running that part at row 350 but it seems to want to carry on for infinity!
Bookmarks