I stuck with this. Seems easy at first then I got lost!
What I am aiming for:
- to insert a row(s) based on a cell value (Col C) -- insert row(s) below
- after a new row(s) is inserted, copy the data from previous row + string value from previous row, removing that value as well from the previous row.
I am trying to use this formula but I got lost...
function addRows(){
var ss = SpreadsheetApp.getActive();
var sheet1 = ss.getSheets()[1];
var dataRange = sheet1.getDataRange();
var dataValues = dataRange.getValues();
for (var i = 0; i<dataValues.length; i++) {
for (var j= 0; j<dataValues.length; i++) {
/* If blank or 0 - zero, skip */
if (dataValues[i][3] == "" || dataValues[i][3]== 0) {continue;}
/* If value is >=1, insert new row(s) below the active row */
if (dataValues[i][3] >=1) {
sheet1.insertRowAfter(i);
sheet1.getRange(...) // copy the data from previous + string
}
}
}
}
