I have a piece of code which is pretty straight forward:
Dim r As Integer, c As Integer
Dim rcnt As Integer, ccnt As Integer
With ActiveSheet
.Unprotect
Application.ScreenUpdating = False
rcnt = .UsedRange.Rows.Count
ccnt = .UsedRange.Columns.Count
For r = 3 To rcnt
For c = 1 To ccnt
If Not .Cells(r, c).Locked Then
.Cells(r, c) = ""
End If
Next
Next
Application.ScreenUpdating = True
ThisWorkbook.ProtectSheet ActiveSheet
End With
It is run as part of a larger context where I manually shuffle stuff into several sheets from an external file. The really, really odd thing is that when I execute the larger set of procedures (of which this snippet is a part) it will be very, very slow (30-70 seconds). However, if I hit CTRL-BREAK, step into debug mode, and then immediately resume excecution, the code performs as expected, meaning sub-second time span for all consecutive sheets.
I'm posting here to see of someone has run across a similar behaviour, and if so, how did you fix it?
Thanks in advance!
/Martin Rydman