简体   繁体   中英

Excel “Array Constants” not readable as VBA Arrays (without parsing)

Excel allegedly allows the storage of arrays of constants in individual cells (eg A1 ={1,2,3,4,5} ). This is referred to as an "Array Constant." This should make for a very powerful feature allowing users to get more than 2 dimensions out of a spreadsheet. However, I can't seem to figure out how to extract the actual data without having to parse it as a string first. The latter method defeats the whole purpose of the array constant.

If one gets Range('A1').Value from the example above, it returns 1 .

Also, IsArray(Range("A1")) returns False while IsArray(Range("A1:A2")) returns True .

Am I missing something, or are these "Array Constants", not actually "Arrays" but just Strings or Doubles?

Am I missing something...

I'm afraid you may be... ;-(

Here's the relevant text from the article

To create a horizontal constant

  1. Use the workbook from the previous column, or start a new workbook.

  2. Select cells A1 through E1.

  3. In the formula bar, enter the following formula and press CTRL+SHIFT+ENTER:

So the article doesn't show an array being stored in a single cell, but a range of cells. Entering the formula as described in a single cell will return the first element in the array only. Checking the Value property for the range using VBA confirms this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM