Attempted to access index 50 from array with length 50!

Be careful if the array can be empty as well though, in that case you’d get 0 to -1 as the indices. Is there any specific reason you can’t use For Each Loop to iterate directly over the elements of the array?