Home > Software engineering >  Why to write data from the array into the Row, consumes huge memory?
Why to write data from the array into the Row, consumes huge memory?

Time:09-28

Sheets (1) in a line, write many times Sheets (2), I have used two methods:

 Private Sub (A) 
Dim Arr As the Variant
Dim As Long I

Arr=Sheets (1). The Rows (1)
For I=1 To 5000
Sheets (2). Rows (I)=Arr
DoEvents
Next I

End Sub


Private Sub (B)
Dim As Long I

For I=1 To 5000
Sheets (1). Rows (I) Copy Destination:=Sheets (2). The Rows (I)
DoEvents
Next I

End Sub

I found that, after each For method A memory are constant, and B will always increase,
Why is this?

CodePudding user response:

When the second method should be replicated in memory retains a large amount of data...

CodePudding user response:

Help you to test the discovery after (repeat RUN many times)

Methods A memory=17 MB

Methods the memory B=17 MB

And didn't find strange


  •  Tags:  
  • VBA
  • Related