I'm trying to create a google script that will look at my sheet, get the length of data and then mark "processed" in Column P. I can't do this with an array/if formula because I need to know when a new line comes in and has not been processed. My current script just writes never ending data to column P. I want it to only write to the last non blank row based on Column A.
Here is my example sheet and script that isn't working.
https://docs.google.com/spreadsheets/d/13Q4I91O4vMDSCHwAMG0DOLLkbzLCxWiQzbugJ-6nPjs/edit?usp=sharing
function MarkrowsProcessed() {
var spr = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spr.getSheetByName("Sheet1");
var column = spr.getRange('A:A').getValues();
for (var i = 0; i < column.length; ++i)
{
var rowData = column[i];
var emailSent = rowData[16];
if (emailSent != 'Processed')
{
sheet.getRange(i+1, 16, column.length, 1).setValue('Processed');// Make sure the cell is
updated right away in case the script is interrupted
}
}
}
Thanks in advance for the help.