Question

I would like my Google spreadsheet to automatically apply formulas found in cells F2 to H2 to all new, form-inserted rows. You can view the spreadsheet here.

The formulas are:

F2: =IF(B2, "I"&B2,"--")

G2: =vlookup(C2,SectionID!$A$2:$B$13,2,FALSE)

H2: =vlookup(D2,ReporterID!$A$2:$B$12,2, FALSE)

I have tried manually applying the formulas to rows 3 to 10, but when a form is submitted, the data is added to newly created rows which do not contain the formulas. (Form data is submitted to columns A to E.)

Feel free to make changes to the spreadsheet.

Thank you for your help.

Was it helpful?

Solution

You will need to either use a script to populate the formulae on form submission, or use the out-of-the-box solution which is an array formula:

=ArrayFormula(IF(A2:A;IF(B2:B;"I"&B2:B;"--");IFERROR(1/0)))

=ArrayFormula(IFERROR(VLOOKUP(C2:C;SectionID!$A$2:$B$13;2*SIGN(ROW(A2:A));FALSE)))

=ArrayFormula(IFERROR(VLOOKUP(D2:D;ReporterID!$A$2:$B$12;2*SIGN(ROW(A2:A));FALSE)))

Here is a bit of discussion about the trick involved in converting VLOOKUP to iterate down an array.

You can also invoke formulae in row 1 to populate the headers as well, which mitigates against the scenario where a row might be inserted above row 2:

=ArrayFormula(IF(ROW(A:A)=1;"IssueID";IF(A:A;IF(B:B;"I"&B:B;"--");IFERROR(1/0))))

=ArrayFormula(IF(ROW(A:A)=1;"SectionID";IFERROR(VLOOKUP(C:C;SectionID!$A$2:$B$13;2*SIGN(ROW(A:A));FALSE))))

=ArrayFormula(IF(ROW(A:A)=1;"ReporterID";IFERROR(VLOOKUP(D:D;ReporterID!$A$2:$B$12;2*SIGN(ROW(A:A));FALSE))))

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top