I'm trying to run the following script in Google Sheets but I can't get it to stop. Anyone able to advise where I'm going wrong. Thanks
function TriplicateEachLine() {
var ss = SpreadsheetApp.getActive();
var sheet = ss.getActiveSheet();
var cc = ss.getCurrentCell();
//Set New Hedders
ss.getRange('R1').setValue('Stock');
ss.getRange('S1').setValue('Weeks');
ss.getRange('A2').activate();
//Start of Loop Function
while (cc > ""){
ss.getCurrentCell().offset(0, 17).setFormulaR1C1('=R[0]C[-5]-R[0]C[-4]');
ss.getCurrentCell().offset(0, 18).setValue('12 Weeks');
sheet.getRange(ss.getCurrentCell().getRow(), 1, 1, sheet.getMaxColumns()).activate();
ss.getActiveSheet().insertRowsAfter(ss.getActiveRange().getLastRow(), 1);
ss.getActiveRange().offset(ss.getActiveRange().getNumRows(), 0, 1, ss.getActiveRange().getNumColumns()).activate();
sheet.getRange(ss.getCurrentCell().getRow() - 1, 1, 1, sheet.getMaxColumns()).copyTo(ss.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
ss.getCurrentCell().offset(0, 17).setFormulaR1C1('=R[0]C[-5]-R[0]C[-4]');
ss.getCurrentCell().offset(0, 18).setValue('8 Weeks');
sheet.getRange(ss.getCurrentCell().getRow(), 1, 1, sheet.getMaxColumns()).activate();
ss.getActiveSheet().insertRowsAfter(ss.getActiveRange().getLastRow(), 1);
ss.getActiveRange().offset(ss.getActiveRange().getNumRows(), 0, 1, ss.getActiveRange().getNumColumns()).activate();
sheet.getRange(ss.getCurrentCell().getRow() - 2, 1, 1, sheet.getMaxColumns()).copyTo(ss.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
ss.getCurrentCell().offset(0, 17).setFormulaR1C1('=R[0]C[-5]-R[0]C[-4]');
ss.getCurrentCell().offset(0, 18).setValue('4 Weeks');
ss.getCurrentCell().offset(1, 0).activate();
}
Browser.msgBox("Complete!");
};
cc, so the while condition will never change. - Diegoccdoesn't get updated. Make these two changes and try again: (1)var cc = ss.getCurrentCell().getValue(); and (2)cc = ss.getCurrentCell().offset(1, 0).activate().getValue();. - Diegocc != "", notc > "". - Diego