How do I fix the Not Responding
error in Excel VBA?
My code is perfect, I'm not getting any error but after I run it, I will see NOT RESPONDING
top of Excel VBA and Excel doesn't respond anymore.
I am writing vba code to find the match numbers between two sheets: Sheet1
holding 5000 numbers and Sheet2
holding 4500 numbers. When I run it, my code run it for 10 secs then excel freezing on me and not responding msg appear top of the screen.
When I compary only 100 numbers between two sheets, it works perfectly and not responding message does not appear. It only occurs when I compare 10000 numbers together or larger amount of numbers.
Once again this code is working perfectly, when I am comparing only 100 numbers. But when I try to do larger numbers between two sheets, "not responding" appears and excel freezes. Here is my code and I did try screenupdate or others, but nothing helpes. I will really appreciate, if someone help me out.
Dim Sheet1rows As Long, Sheet2rows As Long, a as long, j as long
j = 1
a = 1
Sheet1rows = Sheets("Sheet1").UsedRange.Rows.Count + 1
Sheet2rows = Sheets("Sheet2").UsedRange.Rows.Count + 1
For i = a To Sheet1rows
For ii = a To Sheet2rows
'this one is copying between to sheets
If Sheets("Sheet1").Cells(i, 1) = Sheets("Sheet2").Cells(ii, 1) Then
Sheets("Sheet3").Range("A" & j) = Sheets("Sheet1").Cells(i, 1)
j = j + 1
next ii
next i