Excelpromax123
Board Regular
- Joined
- Sep 2, 2021
- Messages
- 172
- Office Version
- 2010
- Platform
- Windows
Hi guys!. I have used the code below to filter data from Sheet data , At variable A (cell M5 ) when the value is >=560,000, the code still runs 4 5 times, then runs again, shows Out of memory error, And gives an error at the line
sArr = Sheets("aaa").Range("AA1:AQ" & a).Value . Ask people to correct the code or switch to a new algorithm so that there is no Out of memory error. I sincerely thank
sArr = Sheets("aaa").Range("AA1:AQ" & a).Value . Ask people to correct the code or switch to a new algorithm so that there is no Out of memory error. I sincerely thank
VBA Code:
Sub abcd()
Application.ScreenUpdating = False
On Error Resume Next
Dim sArr(), dArr(), I As Long, K As Long, R As Long, Col As Long, a As Long, Dk1 As String, xx As Long
a = Range("m5").Value
Dk1 = Range("a2").Value
[B]sArr = Sheets("aaa").Range("AA1:AQ" & a).Value[/B]
R = UBound(sArr)
ReDim dArr(1 To R, 1 To 19)
For I = 1 To R
If (UCase(sArr(I, 9)) = UCase(Dk1) Or UCase(sArr(I, 9)) Like UCase(Dk1) & "-*") Then
K = K + 1
dArr(K, 1) = sArr(I, 2) & " x " & sArr(I, 9)
For Col = 2 To 18
dArr(K, Col) = sArr(I, Col - 1)
Next Col
dArr(K, 19) = sArr(I, 2) & " x " & sArr(I, 9)
End If
Next I
Range("R2:BC260000").ClearContents
Range("R2").Resize(K, 19) = dArr
Application.ScreenUpdating = True
End Sub