Populating VBA dynamic arrays

前端 未结 5 1119
悲哀的现实
悲哀的现实 2020-12-07 13:19

The following code gives me error 9 \"subscript out of range\". I meant to declare a dynamic array so that the dimension changes as I add elements to it. Do I have to create

5条回答
  •  情书的邮戳
    2020-12-07 13:59

    in your for loop use a Redim on the array like here:

    For i = 0 to 3
      ReDim Preserve test(i)
      test(i) = 3 + i
    Next i
    

提交回复
热议问题