简体   繁体   中英

Google Sheets Add row based on cell number value the count of cell which has value

  • Consider colD contains some value I need to insert rows below based on col D value and it should include the cell containing value. Exp: If cell value D is 1 it should not add any row but if it 2 it should add one row below and it should be loop for all the rows using get.dataRange for creation of rows. Thanks for the help in advance**1]

If you want to add new rows, try appendRow() method.

Example:

const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheets()[0];

// Appends a new row with 3 columns to the bottom of the
// spreadsheet containing the values in the array
sheet.appendRow(["a man", "a plan", "panama"]);

There are more methods to test, take a look on:

Example:

const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheets()[0];
// Shifts all rows down by three
sheet.insertRows(1, 3);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM