Assume the following:
Cell A1 = 20
Cell A2 = 35
Cell A3 = 45
=SUM(A1:A3) = 100
But I want to have those 3 values within one single cell as an array like A4 ={"20";"35";"45"} and do
= SUM(A4). However, when I do this, the result = 20. When I read the cell value of A4 with VBA, Range(A4).Value = 20 and IsArray(Range(A4))=False. Meaning it only reads the first element of the array, and does not considers the cell as an array.
I've read solutions like inserting all the values in cells and naming the range. This does not work for me since my arrays could be quite extensive and I will have an array without a fixed length for each row in a table.
The only feasible solution I see is to input the whole array like a string inside a cell like = 20,35,45 and then create a User-defined-Function (UDF) SUM version that reads that string and converts the content to an Array. If the string has at least one comma, then the number of elements in the array would be the number of "," + 1.
Is there another/easier solution for this?
References:
https://www.excelforum.com/excel-formulas-and-functions/1182977-single-cell-array.html
https://www.ablebits.com/office-addins-blog/2015/02/25/array-formulas-functions-excel/
http://www.vbaexpress.com/forum/showthread.php?22816-Solved-Reading-one-cell-value-into-an-array
Cell A1 = 20
Cell A2 = 35
Cell A3 = 45
=SUM(A1:A3) = 100
But I want to have those 3 values within one single cell as an array like A4 ={"20";"35";"45"} and do
= SUM(A4). However, when I do this, the result = 20. When I read the cell value of A4 with VBA, Range(A4).Value = 20 and IsArray(Range(A4))=False. Meaning it only reads the first element of the array, and does not considers the cell as an array.
I've read solutions like inserting all the values in cells and naming the range. This does not work for me since my arrays could be quite extensive and I will have an array without a fixed length for each row in a table.
The only feasible solution I see is to input the whole array like a string inside a cell like = 20,35,45 and then create a User-defined-Function (UDF) SUM version that reads that string and converts the content to an Array. If the string has at least one comma, then the number of elements in the array would be the number of "," + 1.
Is there another/easier solution for this?
References:
https://www.excelforum.com/excel-formulas-and-functions/1182977-single-cell-array.html
https://www.ablebits.com/office-addins-blog/2015/02/25/array-formulas-functions-excel/
http://www.vbaexpress.com/forum/showthread.php?22816-Solved-Reading-one-cell-value-into-an-array