I have a macro (below) that is designed to run 150,000 iterations to completion. However, after running the code for more than 1000 iterations, Excel enters "Not Responding" mode, and then crashes. I left it for more than 12 hours, but it did not improve. Previously, the code was used to run the first 100,000 iterations and to run up to 1,048,576 iterations in steps of 250,000.
Failure also leads to disabling Outlook, IE, as well as to Chrome (although I did not start them at the same time, but still a failure).
If I run the code through F8 or to a breakpoint through F5, the code works fine. However, this is impractical for another 948 576 iterations.
Any suggestions on how to solve the problem so that it doesn't crash all the time?
System Specifications: Excel 2010 i5 (3rd Gene) RAM 8GB
code:
Dim a As Variant Dim b As Variant Dim c As Variant Dim d As Variant Dim e As Variant Dim i As Integer Dim j As Double Dim strResult As Double a = 1 b = 100001 While b <= 250000 While a <= 12 If a = 1 Then If Cells(b, 14) = "EEEE" Then Cells(b, a) = 1234 ElseIf Cells(b, 14) = "ZYXW" Then Cells(b, a) = 2468 ElseIf Cells(b, 14) = "AAAA" Then Cells(b, a) = 3579 ElseIf Cells(b, 14) = "BBBB" Then Cells(b, a) = 9764 ElseIf Cells(b, 14) = "DDDD" Then Cells(b, a) = 8631 Else Cells(b, a) = "ZZZZ" End If ElseIf a = 2 Then If Cells(b, 15) = 5 Then Cells(b, a) = "JPY" ElseIf Cells(b, 15) = 4 Then Cells(b, a) = "GBP" ElseIf Cells(b, 15) = 3 Then Cells(b, a) = "CHF" ElseIf Cells(b, 15) = 2 Then Cells(b, a) = "USD" ElseIf Cells(b, 15) = 1 Then Cells(b, a) = "EUR" Else Cells(b, a) = "YYYY" End If ElseIf a = 3 Then If Cells(b, 16) = 10234 Then Cells(b, a) = "A27Z2" ElseIf Cells(b, 16) = 10420 Then Cells(b, a) = "B28Y" ElseIf Cells(b, 16) = 10432 Then Cells(b, a) = "C29X" ElseIf Cells(b, 16) = 18953 Then Cells(b, a) = "D30W" ElseIf Cells(b, 16) = 21048 Then Cells(b, a) = "E31V" ElseIf Cells(b, 16) = 36542 Then Cells(b, a) = "F32U" ElseIf Cells(b, 16) = 36954 Then Cells(b, a) = "G33T" ElseIf Cells(b, 16) = 65425 Then Cells(b, a) = "H34S" ElseIf Cells(b, 16) = 75963 Then Cells(b, a) = "I35R" ElseIf Cells(b, 16) = 84563 Then Cells(b, a) = "J36Q" Else Cells(b, a) = "XXXX" End If ElseIf a = 4 Then strResult = 1 For i = 1 To Len(Cells(b, 18)) Select Case Asc(Mid(Cells(b, 18), i, 1)) Case 65 To 90: strResult = strResult + Asc(Mid(Cells(b, 18), i, 1)) - 64 Case Else strResult = strResult + Mid(Cells(b, 18), i, 1) End Select Next j = WorksheetFunction.CountIfs(Range("A1:A" & b), Range("A" & b), Range("B1:B" & b), Range("B" & b)) Cells(b, a) = Cells(b, 1) & " - " & Cells(b, 2) & strResult & " - " & j ElseIf a = 5 Then Cells(b, a) = Cells(b, 17) ElseIf a = 6 Then If Cells(b, 19) = "SB" Then Cells(b, a) = "Sub" ElseIf Cells(b, 19) = "RD" Then Cells(b, a) = "Red" Else Cells(b, a) = "XXXX" End If ElseIf a >= 7 Then Cells(b, a) = Cells(b, a + 13) End If a = a + 1 Wend b = b + 1 a = 1 Wend Columns("M:Q").Select Selection.Delete Shift:=xlToLeft Columns("N:V").Select Selection.Delete Shift:=xlToLeft