In a program I am writing I cycle through some arrays in order to get rid of a few unwanted values. the loop goes through the array and finds the value it doesn't like and then shifts each element after that up one. When the loop completes, I am left with a bunch of elements (not empty) that I do not want at the back of the array, I want to resize the array so that it is just big enough to hold the data I want. In short I am using the ReDim Preserve statement to cut off the unwanted back end of an array. the error message I get is 'runtime error 9 subscript out of range'. I don't understand why this is so, I've tried a couple of different ways to write the statement but nothing is working.
The code and a variable index follows:
ReDim Preserve day1(1 To UBound(day1) - i, 1 To 1)
UBound(day1) = the current length of the array = 2091
i = the number of times array elements have been shifted up, thus the number of extra array elements I have at the end.
If more code is required I can provide it.
The code and a variable index follows:
ReDim Preserve day1(1 To UBound(day1) - i, 1 To 1)
UBound(day1) = the current length of the array = 2091
i = the number of times array elements have been shifted up, thus the number of extra array elements I have at the end.
If more code is required I can provide it.