I need your help with regard to my script below. I have 2 sheets (sheet1 and sheet2). Sheet1 contains the cell values in which this will be copied/to update cells in sheet2. The script will add and copy values from sheet1 to sheet2, but it will not recognize the condition. What i would like to happen is, if sheet2!c3 = sheet1!f5
will just update the cells, else it will add another row and copy the datas from sheet1 to sheet2.
Thanks for the help!
function emailongoing() {
var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('OutageYellow');
var sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('test');
var lastRow = sheet2.getLastRow()+1;
cntr = 0
if (sheet2.getRange('C3') != sheet1.getRange('F5')) {
sheet1.getRange('E5').copyTo(sheet2.getRange(lastRow + cntr,2), {contentsOnly:true});
sheet1.getRange('F5').copyTo(sheet2.getRange(lastRow + cntr,3), {contentsOnly:true});
sheet1.getRange('C5').copyTo(sheet2.getRange(lastRow + cntr,5), {contentsOnly:true});
sheet1.getRange('C7').copyTo(sheet2.getRange(lastRow + cntr,4), {contentsOnly:true});
sheet1.getRange('C8').copyTo(sheet2.getRange(lastRow + cntr,9), {contentsOnly:true});
sheet1.getRange('C9').copyTo(sheet2.getRange(lastRow + cntr,10), {contentsOnly:true});
cntr++;
}
else if (sheet2.getRange('C3') != " ") {
sheet1.getRange('E5').copyTo(sheet2.getRange(lastRow + cntr,2), {contentsOnly:true});
sheet1.getRange('F5').copyTo(sheet2.getRange(lastRow + cntr,3), {contentsOnly:true});
sheet1.getRange('C5').copyTo(sheet2.getRange(lastRow + cntr,5), {contentsOnly:true});
sheet1.getRange('C7').copyTo(sheet2.getRange(lastRow + cntr,4), {contentsOnly:true});
sheet1.getRange('C8').copyTo(sheet2.getRange(lastRow + cntr,9), {contentsOnly:true});
sheet1.getRange('C9').copyTo(sheet2.getRange(lastRow + cntr,10), {contentsOnly:true});
cntr++;
}
}