The following code results in a huge jump in memory (that isn't released once its run) even though there is only 2 Integer variables and 1 String variable. Its a simplified version of some 'real code' which makes VBA run out of memory and crash. Any ideas what's going on and how to resolve?
Sub test()
Dim Loop1_Count As Integer
Dim Loop2_Count As Integer
Dim A As String
Loop1_Count = 1
Do While Loop1_Count <= 1000
Loop2_Count = 1
Do While Loop2_Count <= 1000
A = Workbooks("Test.xlsm").Worksheets("Test").Cells(Loop2_Count, "A")
Loop2_Count = Loop2_Count + 1
Loop
Loop1_Count = Loop1_Count + 1
Loop
End Sub
<strike></strike>
The above code lives in Test.xlsm.
"Test" is a worksheet in Test.xlsm and contains only blank cells
Sub test()
Dim Loop1_Count As Integer
Dim Loop2_Count As Integer
Dim A As String
Loop1_Count = 1
Do While Loop1_Count <= 1000
Loop2_Count = 1
Do While Loop2_Count <= 1000
A = Workbooks("Test.xlsm").Worksheets("Test").Cells(Loop2_Count, "A")
Loop2_Count = Loop2_Count + 1
Loop
Loop1_Count = Loop1_Count + 1
Loop
End Sub
<strike></strike>
The above code lives in Test.xlsm.
"Test" is a worksheet in Test.xlsm and contains only blank cells