I have a worksheet with roughly 300'000 rows of which a portion needs to be deleted.
I populate an array with row numbers, and perform a delete procedure for the rows in that array:
Sub Start()
'...
b = 0
ReDim arr(b)
For i = LRow To 2 Step -1
If .Cells(i, "L").Value = "" then
ReDim Preserve arr(b)
arr(b) = i
b = b + 1
End If
Next i
.Range("A" & Join(arr, ",A")).EntireRow.Delete
'...
End Sub
With the code above, arr ends up containing some 68'000 row numbers.
On the line that ought to delete these rows, I get the error
Method 'Range' of object '_Worksheet' failed
This also occurs when I try to select these, instead of deleting them.
Taking a portion of the output from the Join function performs as expected, such as:
.Range("A" & "2465,A2457,A2432,A2428,A2410,A2405,A2376,A2372,A2358,A2354").EntireRow.Delete
What causes the code to fail? Is there a limit on the Range object I am unaware of?