Google-sheets – Set formula into a cell based on content of another cell

formulasgoogle sheetsgoogle-sheets-arrayformulaimportrange

Google Sheets:

I would like to set a formula into a cell, but this should depend on content of another cell.

Example Google Sheet (anybody can edit):
https://docs.google.com/spreadsheets/d/1Z2VVLH5saVKJQ97xUNTZ4vssXnw9Q_ruyQF61tCbxsU/edit?usp=sharing

Goal (old):

The RED "aaa" cell change should set the BLUE "changeme" content to

  • "aaa", if "aaa"
  • "", if "nothing"
  • "=ROUNDUP((1+2)/2)", if "myformula"
  • "=SUM(1+2)", if "myformula2"

EDIT1:

To make the definition clearer, I created a new worksheet "sheet_new (editable)" on the example Google Sheet:

Goal (new):

The RED cell change should set the BLUE content to:

  • Formula, if RED cell is set to Automatic
  • Empty cell, if RED cell is set to Manual

I hope it is clearer now.

Probably using importrange or arrayformula would be the solution.

EDIT2:

If RED cell is set to Manual the user can enter numbers manually to BLUE cell. If RED cell is set to Automatic, the value of BLUE cell will be a formula, which calculates the value.

Best Answer

OK, here is the formula I supplied:

=IFS(B3="aaa","aaa",B3="nothing","",B3="myformula",ROUNDUP((1+2)/2),B3="myformula2",SUM(1+2))

It should be pretty easy to understand (i.e., condition, result, condition, result, etc.).