ReDim Preserve error

I am trying to redim preserve a two dimensional array. at the very top of my code I have:

Dim BayQuestionArray() As Variant Dim numberofbay As Double

I have two buttons, the first button is for initializing the array size:

numberofbay = 1 ReDim Preserve BayQuestionArray(numberofbay, 37)

and the second button is for upsizing the array

ReDim Preserve BayQuestionArray(numberofbay + 1, 37)

The second button doesn't work, it keeps giving me an error saying Run time error 9 Subscript out of range. Why?


When using Preserve to resize an array variable (declared as such, not as Variant), you may only alter the upper boundary of the last dimension. You would need to transpose your array, or use a jagged array or other structure like a Dictionary/Collection.


The "redim preserve" command was altered recently due to a security patch. This patch effects ALL scripts using "redim preserve" written before the patch. Previous to the patch your code would have worked as written.

All "redim preserve" commands that changed the lower bound of the array no longer work. It will appear as if the code just ignores the line which can make diagnosis of effected scripts/code difficult because the first warning that the "redim preserve" is not working as expected will occur with the overflow error, potentially far from the "redim preserve" command.

For more info on the vulnerability that prompted the security patch (and to prove I am not making this up) you can reference:



  • Replace values in data frame with other values according to a rule
  • Swift 3.0 convert Double() to NSMutableAttributedString
  • Using double loop to fill a matrix in R
  • MATLAB-How to put one image on another?
  • Product and product template in Odoo 10
  • Spree, Ruby on Rails - Add to cart multiple variants of the same product
  • Shopify API CARTS - Changing line_item line_price for price Override
  • Receive custom intent without activity restart
  • NHibernate proxyexception
  • Can't compile Arduino CapSense example
  • Not able to display correct data in table -AngularJS
  • R sqldf renaming a field in a select statement
  • react split panel resize
  • Available space left on drive - WinAPI - Windows CE
  • can variables be set randomly when declaring them again?
  • SAXReader not re-ecape characters
  • How can I set a binding to a Combox in a UserControl?
  • Calling Worksheet functions from vba in foreign language versions of Excel
  • Excel's Macro-Recorder usage
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Does CUDA 5 support STL or THRUST inside the device code?
  • How to handle AllServersUnavailable Exception
  • Weird JavaScript statement, what does it mean?
  • VBA Convert delimiter text file to Excel
  • How do you troubleshoot character encoding problems?
  • SVN: Merging two branches together
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • How to format a variable of double type
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Linking SubReports Without LinkChild/LinkMaster
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Reading document lines to the user (python)
  • How to Embed XSL into XML
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize