Assuming that localArray is a single dimensional array, change the code to. For i = LBound(localArray) To ...
stackoverflow.com