Google-sheets – Transfer a row to another sheet then clear the original row

google sheetsgoogle-apps-script

I saw this problem and the answer was perfect except that I do not want to delete the row. I only need the cells cleared of existing values.

How to move a row into another sheet?

Best Answer

  • you can use something simple like this to "clear" the row either via the button or by including it in the previous script to be auto-executed

    function moveValuesOnly() { var ss = SpreadsheetApp.getActiveSpreadsheet();
                                var source = ss.getRange("Sheet1!X1");
                            source.copyTo(ss.getRange("Sheet1!A2"), {contentsOnly: true}); 
                            source.copyTo(ss.getRange("Sheet1!B2"), {contentsOnly: true});
                            source.copyTo(ss.getRange("Sheet1!C2"), {contentsOnly: true});
                            source.copyTo(ss.getRange("Sheet1!D2"), {contentsOnly: true});
                            source.copyTo(ss.getRange("Sheet1!E2"), {contentsOnly: true});
                            source.copyTo(ss.getRange("Sheet1!F2"), {contentsOnly: true});
                            source.copyTo(ss.getRange("Sheet1!G2"), {contentsOnly: true}); }

  • where Sheet1!X1 is the empty cell that gets copied over the mentioned cells