I have a google spreadsheet which is connected to a google forms
I wanted one formula to be automatically copied to the new lines(Column R) when google form response is submitted
the spread sheet: https://docs.google.com/spreadsheets/d/1Z7uUBnzS5zKnxGswKKNAgn2XbRunqIzQZMATDl7skoE/edit#gid=1300745141
the formula:
if($O6="UZS",index(googlefinance("currency:UZSUSD","price",$B6),2,2)**$P6,if($O6="EUR",index(googlefinance("currency:EURUSD","price",$B6),2,2)*$P6,$P6)))
Best Answer
You want to insert a formula into Column R when a form submission is received.
As outlined in the comments:
onformSubmit
trigger to take action when a new submission is received. This is installable Trigger, so you will need to ... install it.setFormula(formula)
to insert the formula into the sheet.Three things to note about your formula:
IF
statement includes several instances of evaluating a string. These necessarily require opening and closing double quotes("). However, double quotes are also required to substitute the reference to the row number. So, internal double quotes are escaped () and each instance of a row number in your formula has been substituted with"+row+"
. The end result is that the formula is dynamic regarding the submission row.