Hello,
I got the following code from the forum (and it's working perfectly)
Dim array1 As Variant
array1 = Array("... cats ...", " ...Dogs ...", " ...Cats and dogs ...", "another text")
Dim array2 As Variant
array2 = Array()
Dim t
For Each t In array1
If InStr(1, t, "cats", vbTextCompare) > 0 Or InStr(1, t, "dogs", vbTextCompare) > 0
Then
ReDim Preserve array2(UBound(array2) + 1)
array2(UBound(array2)) = t
End If
Next
The only problem is that as my data increases, the VBA becomes very slow. Due to numerous ReDim Preserve.
I want to try something:
If we don't define array2 as a dynamic array, we can define it as a static array like this:
Dim Array2(0 To 1000000)
This will avoid the need to ReDim Preserve array2 at each loop.
Can anybody help me modify the above code so that array2 is populated correctly?
Suppose only 200,000 rows are copied to array2.
How can I delete the 800,000 unnecessary blank rows in array2?
Thanks
Leon