Fill down - Google Apps Script for Spreadsheets

后端 未结 4 1706
甜味超标
甜味超标 2020-12-13 09:34

Is there a function that can fill down data to all empty cells from the row above?

If not, could anyone help me out with a Google Apps Script (or other solution) tha

4条回答
  •  有刺的猬
    2020-12-13 10:31

    var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Name");
    var formulas = sheet.getRange(10, 1, 1, 10).getFormulasR1C1();
    var newRange = sheet.getRange(11, 1, 1, 10);
    newRange.setFormulasR1C1(formulas);
    

    Using getFormulasR1C1() and then setFormulasR1C1(formulas) This function imitates mouse dragging of the formula

    Please note that if the cell doesn't contain formula it will show error. You will need to work around this problem by emptying the cells.

提交回复
热议问题