I have created an array for a data dump over 35k rows long. I want to only add items in the array that contain 16250 (about 1100 items). So far I've created an array, but it goes all the way to 35k. How do I shorten the limit of the array to stop once the last cell with 16250 is added?
Dim A(), i as long, j as integer
nr = WorksheetFunction.CountA(Range(Cells(2, 1), Cells(2, 1).End(xlDown))) + 1
nc = Range(Cells(2, 1), Cells(2, 1).End(xlToRight)).Columns.Count
'CBK Array A()
ReDim A(3 To nr, 1 To nc)
For i = 3 To nr
For j = 1 To nc
A(i, j) = Cells(i, j)
End If
Next j
Next i
'create sheet specific array
Dim shArr()
ReDim shArr(3 To nr, 1 To nc)
For i = 3 To nr
For j = 1 To nc
If Left(A(i, 4), 5) = "16250" Then
shArr(i, j) = A(i, j)
End If
Next j
Next i
So array A goes to 35k, but I want ShArr to only go to around 1100.
I have tried ubound(a), but it included the empty cells even thought I heard from Chat GTP that it shouldn't.