ReDim preserve gives "subscript out of range"

bertjeiv

New Member
Joined
Sep 23, 2010
Messages
32
My script runs through the array to look if a certain value already exists in faultArray(x,1) and if it does then faultArray(x,2) gets incremented. If it does not exist in they array I redimension it to add another set of values to it with this line:

Code:
ReDim Preserve faultArray(1 To UBound(faultArray, 1) + 1, 1 To 2)

I get Run-time error '9': Subscript out of range...

thanks fot the help
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You can only redim preserve the last dimension of an array.
 
Last edited:
Upvote 0
if you use Preserve, that is. And you can only alter the upper bound.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,845
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top