Get length of array?

前端 未结 5 1000
北海茫月
北海茫月 2020-12-13 08:13

I\'m trying to get the length of an array, yet I keep getting this error:

Object required

Am I doing something wrong?

         


        
5条回答
  •  感情败类
    2020-12-13 09:05

    Length of an array:

    UBound(columns)-LBound(columns)+1

    UBound alone is not the best method for getting the length of every array as arrays in VBA can start at different indexes, e.g Dim arr(2 to 10)

    UBound will return correct results only if the array is 1-based (starts indexing at 1 e.g. Dim arr(1 to 10). It will return wrong results in any other circumstance e.g. Dim arr(10)

    More on the VBA Array in this VBA Array tutorial.

提交回复
热议问题