VBA (Excel) Initialize Entire Array without Looping

后端 未结 6 507
有刺的猬
有刺的猬 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 17:02

    Fancy way to put @rdhs answer in a function:

    Function arrayZero(size As Integer)
      arrayZero = Evaluate("=IF(ISERROR(Transpose(A1:A" & size & ")), 0, 0)")
    End Function
    

    And use like this:

    myArray = arrayZero(15)
    

提交回复
热议问题