Run-time Error 9: Subscript out of Range using Redim Preserve

When you use Redim Preserve you may occassionally come across the error “Run-time Error 9: Subscript Out of Range”.

If you use Preserve then you can only resize the last dimension in your array.  You must also specify for every other dimension the bound it had in the existing array.

So, for example, if your array has one dimension then you can resize that dimension and still preserve all the data of that array because you are changing the only dimension, which also happens to be the last dimension.  If your array has multiple dimensions (two or more), then you can only change the size of last dimension if you use Preserve

Leave a Reply

Your email address will not be published. Required fields are marked *