Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9786

Generate formula programmatically

$
0
0

I am trying to generate a large number of formulas programmatically.

I can easily generate a formula text doing something like ="=1+1" (in reality it will be a bit more complex). This will output the string =1+1 in the cell.

I can then copy-paste_as_values the content of this cell in another cell. This new cell will now contain =1+1. This should be a formula and the cell should display 2. However, for some reason, the formula is not evaluated and =1+1 is displayed. Note that there are no quotation marks in the cell content. In theory there should be no way for a cell containing =1+1 to not display 2. The weird part is that when I select the cell, the cell code is linted as it was a proper formula, still the result is not shown...

The only way I found is to delete the = sign, press enter, go back to the same cell, add the = again, and press enter again.

Is there a way to "refresh" Google Sheet to let him interpret the formula properly?

NOTE:I know this is not the "proper" way of doing this. I could simply keep the variable part of the formula in an array and reference it. However, due to the way the spreadsheet is organised, this would become cumbersome and ugly.

EDIT: Working example

I'm adding a working example a bit closer to what I need

https://docs.google.com/spreadsheets/d/1ME1V81BnYpOHqe6xc5ZRF2p8RYDJOkvARxv-2iDXkcQ/edit?usp=sharing

I have a tab containing some cells with a value in them. I want to link each of these to the corresponding cell in another tab. Each cell will have a different link, so I found 3 options (that you can see in the example attached):

  1. Add each link manually (impossible as I have more than 400 hundreds!
  2. Use the formula HYPERLINK"hard-coding" the value to search and the label in each formula. Not very different than the solution above as I'd need to have 400 different formulas and arrange them manually
  3. Keep a cell with the name/label and generate the link in another cell using the HYPERLINK formula. Works, but I need two rows/cells where I had one. Also, one becomes completely redundant. Ugly.
  4. Generates the customised formulas as per option 1 programmatically. I can then copy-paste all the formulas generated in the correct place, overwriting the previous value. The result is the same as option 1, but I do this automatically instead than 1 by 1. Here is where I find that if you copy a formula generated programmatically, this is not interpreted as a formula

Viewing all articles
Browse latest Browse all 9786

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>