How to merge multiple formulas

I want to merge several formulas which all result in a final formula and calculates things. it starts with some data cells, and then builds several formulas on those cells:

A1: 10
A2: 3
A3: 6

B1: =A1+A2
B2: =A1+A3

C1: =IF(A1>A3, B1, B2)

Is there a way to programically merge the formula in C1 to =IF(A1>A3, A1+A2, A1+A3) (thus replacing the variables B1 and B2 with their values)?

Why don’t you try your solution? Formula =IF(A1>A3; A1+A2; A1+A3) evaluates the same thing as =IF(A1>A3; B1; B2) does (i.e. there is no need for the intermediate cells B1 and B2)


Or do want to put an arbitrary formula **as text** into `B1` and `B2` and `IF()` evaluates whatever the formula in `B1` and `B2` is? (which afaik is not possible)

@anon73440385 This is a mockup / example of what I actually want to do. The spreadsheet contains about 40 cells that are finally combined, and I would like it to be automated so I wont make any unneccessary mistakes.

For example: if you open the structure tab in the function wizard, you’ll see the breakdown / structure of the formula. If you use brackets () in your formula, you can see it combines it as a “subformula”. I want to insert what the value of a variable is in this structure view, automatically.

So yes, your last guess is what I meant (I did not see it initally, I’m not very used to this forum). From a programmer / computer science standpoint this is rather simple functionality: combining a context free language its rules to end up with a function that works only in terminals. And I’m hoping someone else has made it :stuck_out_tongue:

I’m not aware of any kind of a tool, what I’d call a “create-irrededucible-formula”-generator. In fact, it is the way how I develop complex formulas: Use many intermediate levels, create a formula based on the last intermediate level, and expand the formula by replacing each intermediate level by its formula until it is no longer reducible (and sometimes I’m using an external editor for that )

And I’m hoping someone else has made it :stuck_out_tongue:

I wouldn’t expect. Of course it is a common thing to parse expressions, but there are complications in the context which may make it rather difficult when it must be done from scratch without having access to helpers available in the core code anyway. Think alone of the nonsense (non-)syntax nowadays used for sheet names. What about INDIRECT()? What if a user wants to take advantage of the work, but at the same time to use RC addressing? Start anew then?
In fact I considered the task to some degree about 6 years ago. Decided to let it be. Lots of complications, little use.
If you are interested very seriously, you may study the way parsed formulas are treated in Calc (as seen from the API) and how to use the FormulaParser service and the interface XFormulaParser. I didn’t know about them 6 years ago.