Link to home
Start Free TrialLog in
Avatar of Anthony Mellor
Anthony MellorFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Can this be made to work? Array constant in one cell

User generated image
Edit mode press F9 F9 does work, but not in the sheet.
Trying to avoid macros and vba and named array (need too many)

What I want to do here does work if this is entered into a name as reference to: so that is not an answer I am looking for.

I am looking for an answer that can do maths on 2 x 99 array constants entered in single cells.

Tried with INDIRECT, I'm sure there's something I am forgetting here, to do with being able to make formulae construct themselves.

Here's the typing:
{5,4,3,2,3,4,5;1,2,3,4,5,6,7}
=CONCATENATE("=SUM(INDEX(",A1,",,2))")

and the result of the concatenate (which does work in itself)
=SUM(INDEX({5,4,3,2,3,4,5;1,2,3,4,5,6,7},,2))

How to get that array constant indirectly into the formula?

Anthony
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

No, array constants cannot be sent as variables.

You can, however, send this to a UDF for processing as desired
Hello,

use the Evaluate Formula tool to see what the parts of the formula return and how it all comes together. Evaluate Formula is invaluable when working with arrays.

The formula ...

=SUM(INDEX({5,4,3,2,3,4,5;1,2,3,4,5,6,7},,2))

... sums the second column of each row in the array, i.e. 4 + 2


cheers, teylyn
Indirect() will evaluate a text string and return  a range. Indirect() will do NOTHING to evaluate the contents of a cell, be it an array constant or a novel.

You may want to step back a bit, do some more research and check your premises.

You're asking questions that are based on assumptions that are way off. Excel does not work that way, even if you want it to.

Please do some reading about arrays and array formulas (and their limitations) and try to get a better understanding. Your premises are so far off the mark that it is difficult to suggest a workable solution. You seem to be fixed on this "multiple values in one cell as an array, which can be evaluated by a formula" approach. No. It does not work this way. Otherwise, people and businesses would not be spending big bucks to develop database solutions.

42!
ASKER CERTIFIED SOLUTION
Avatar of barry houdini
barry houdini
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Note: I agree with teylyn, this isn't really a viable option for any robust long-term solution, more of a curiosity....but see attached for demo of above

barry
Evaluate.xls
Avatar of Anthony Mellor

ASKER

The solution is beyond excellence: it works.
Very interesting, so it can be done, after a fashion (meaning macros through a sort of back door).

User generated image
A UDF was where I expected this to go, in fact isn't that what this is....

Amazing what can be achieved when one does not know something cannot be done.

I noticed that the C API has been mapped to the old XLM macro system, something like that, so these old macros may stay around for the foreseeable future.

Anthony
this is for my future reference:

http://www.ozgrid.com/forum/showthread.php?t=52372

The VBA help topic for EVALUATE is a bit vague and probably doesn't do it justice. In fact, after reading through it for yourself, you probably wouldn't see much cause to use it. Here's what it can do:

1. Converts string math expressions to values.
2. Converts 1D and 2D string arrays to their array equivalents.
3. Capable of processing any formula a worksheet cell can process!

That's right, it can do anything a cell can do! It contains all the functionality of a worksheet cell wrapped in a single VBA command. In fact, it can even do one thing that cells can't do... it can return whole arrays. So it's like having free access to a worksheet cell... only it's better than a worksheet cell in the sense that it can evaluate and return arrays.