Reputation: 831
How can I extend my function to check if the new email already exists in column F?
function emailUpdate() {
var ss = SpreadsheetApp.getActiveSheet();
var emailRow = ss.getRange("F2:F").getValues();
var emailRowNum = emailRow.filter(String).length + 1;
var emailNew = ss.getRange("F"+emailRowNum).getValues();
return emailNew;}
So I have a googlesheet with emails saved in column F. I am trying to compare the last row value (emailNew
) with all previous values in column F but I'm unsure how to do that ...
Upvotes: 0
Views: 3158
Reputation: 64062
Comparing the last value in a range with all of the previous values.
function comparelastvalue()
{
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet();
var lastRow=sh.getLastRow();
var rg=sh.getRange(2, 6, lastRow, 1);
var vA=rg.getValues();
var theseRowsEqualTheValueInTheLastRowA=[];
for(var i=0;i<lastRow-2;i++)
{
if(vA[i][0]==vA[lastRow-1][0])
{
theseRowsEqualTheValueInTheLastRowA.push(i+2);
}
}
}
Upvotes: 1