ws1lastrow value in the code below is 147583
I am executing the code below from within the VB Editor. Debug.print is used to keep a track of rows processed. ws1lastrow value is 147583
After executing till 5000 or 6000 (every time the count changes), the Excel stops responding and I have to restart and run.
Any reason why this happens and any solutions/tips for handling this?
Sub IdentifyMissingsNew() Dim ws1 As Worksheet Dim rws As Worksheet Set ws1 = ThisWorkbook.Sheets("New") Set rws = ThisWorkbook.Sheets("DelInt") ws1lastrow = ws1.Cells(Rows.Count, 1).End(xlUp).Row Set lookuprange = rws.Range("a1").CurrentRegion For i = 2 To ws1lastrow ws1.Cells(i, "ae") = Application.VLookup(ws1.Cells(i, "a"), lookuprange, 3, False) Debug.Print i Next i End Sub
DoEvents
after yourDebug.Print i
will probably allow it to continue responding. But you should consider rewriting the code so that it isn't so slow. – YowE3K