VBA (Excel) Initialize Entire Array without Looping

后端 未结 6 501
有刺的猬
有刺的猬 2020-12-07 16:10

I am fairly new to VBA, so this may be a simple question but here goes.

I would like to initialize an entire array myArray, say of integers, in VBA. I k

6条回答
  •  独厮守ぢ
    2020-12-07 16:55

    I want to initialize every single element of the array to some initial value. So if I have an array Dim myArray(300) As Integer of 300 integers, for example, all 300 elements would hold the same initial value (say, the number 13).

    Can anyone explain how to do this, without looping? I'd like to do it in one statement if possible.

    What do I win?

    Sub SuperTest()
       Dim myArray
       myArray = Application.Transpose([index(Row(1:300),)-index(Row(1:300),)+13])
    End Sub
    

提交回复
热议问题