Array from Range in Excel VBA

前端 未结 5 762
孤独总比滥情好
孤独总比滥情好 2020-12-18 02:07

Well I\'ve been struggling with the little bit of code and can\'t seem to get around it ... I\'m trying to get an array from a range of cells, the array however is showing u

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-18 02:24

    That's correct as is. Even if you select an array of cells, you still have the option to select one single cell out of the array (and step for example with tab through the items of this array)

    .Value
    

    only gets you the content of the currently single-selected cell.

    if you want the enumeration of the array, you may call the .Cells()-method of the Range-object

    Assuming that D19 until H19 contain "a" through "e" respectively, calling

    Range("D19:H19").Cells(2)
    

    returns you "b". Note that this is a one-based array and can be 2-dimensional. Cells() takes at most 2 parameters to specify the inner offset from the selection's origin.

    hope that clarifies... regards

提交回复
热议问题