I would like a line to be automatically created above line 2 everyday, that the boxes A2, B2, C2, E2, F2 stay empty, but that the boxes D2 and G2 are filled with the same formulas as the line below.
Do you know if it’s possible to do these 2 actions?
This isn’t something n8n can handle well I am afraid. The Google Sheets node only has an “append” operation inserting a new line at the bottom, not an insert above/insert below another row option.
You would essentially need to re-write the entire sheet to move rows around.
I found a workaround with google Apps Scripts to insert a new line with formulas:
function daily() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName(“N8N”);
sh.insertRowAfter(1);
sh.getRange(“D2”).setFormula(‘=C2/B2’);
}
But you’re right, I can’t append any data in the blank cases between 2 lines… Do you know how I could do this?
Hello!
I used the following script on Google Sheet, and it works well.
function InsertLineGlobalApp() {
var feuille = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Global - app");
// Vérifier si la feuille existe
if (feuille) {
// Ajouter une ligne au-dessus de la ligne 2
feuille.insertRowBefore(2);
// Placer la valeur "1" en cellule A2
feuille.getRange("Y2").setValue("1");
}
}
Then I ask n8n to fill the line that contains the value “1” in the column Y. The first one will be in Y2, so it will fill the line 2
You can also create a script that inserts a row and deploy it. The script can take your variables and use those variables for cell values in an inserted row.
Then in n8n use the HTTP node to call the script with cell content.