Thought I'd share this.
I have been looking for a way to store multiple values in a single cell while having that cell's value be and display the first, or primary value. I found a lot of ideas that just didn't work but I finally came up with my own that does.
In the VBE add a module and creat the following function.
function eval(Byval Target as Range)
eval = application.evaluate(Target.Function)
end function
In your spreadsheet enter an array constant in the cell you wish to hold multiple values: "={4,3,2}" without the quotes but with the curly braces and do not use Ctrl-Shift-Enter as you would if entering an array function. Let's assume cell A1.
The cell will display the value 4 and return that if the cell is used in any formula normally.
To retrieve the other values, or the first explicitly, use the function
=index(eval(A1), 1, n) ;where n can be 1,2, or 3 to return 4,3, or 2 respectively.
I'm sure the above eval function could be made sexier to result in an error if the array bounds are exceeded or other circumstances and that this concept could easily extend to multi-dimensional arrays. However this simple form met my objectives as I was trying to store a risk rating and the corresponding likelihood and impact values from a risk matrix.
I have been looking for a way to store multiple values in a single cell while having that cell's value be and display the first, or primary value. I found a lot of ideas that just didn't work but I finally came up with my own that does.
In the VBE add a module and creat the following function.
function eval(Byval Target as Range)
eval = application.evaluate(Target.Function)
end function
In your spreadsheet enter an array constant in the cell you wish to hold multiple values: "={4,3,2}" without the quotes but with the curly braces and do not use Ctrl-Shift-Enter as you would if entering an array function. Let's assume cell A1.
The cell will display the value 4 and return that if the cell is used in any formula normally.
To retrieve the other values, or the first explicitly, use the function
=index(eval(A1), 1, n) ;where n can be 1,2, or 3 to return 4,3, or 2 respectively.
I'm sure the above eval function could be made sexier to result in an error if the array bounds are exceeded or other circumstances and that this concept could easily extend to multi-dimensional arrays. However this simple form met my objectives as I was trying to store a risk rating and the corresponding likelihood and impact values from a risk matrix.