title: Google Sheets Delete Row if value in a column on one tab to not match a column on other
body: <p>I am trying to make a script in Google Sheets that will check the values in a column on one tab against the values in a column in another tab. </p>
  
  <p>for example; I would like to have a list allowed e-mail addresses in one tab ("Users") and then, from a form I have it entering addresses in the other tab ("Form1"). </p>
  
  <p>If the addresses from the form are not in the Allow list, I would like it to automatically delete that row. </p>
  
  <p>I think my main problem with this code here.</p>
  
  <pre><code>if( entryValues[i] === emailsAllowed[t] )
  </code></pre>
  
  <p>Even tho the values in the arrays match it will never become true. </p>
  
  <pre><code>function onOpen() 
  {
  
    var sheet = SpreadsheetApp.getActiveSpreadsheet(); 
    var s = sheet.getSheetByName('Form1'); //Get the sheet with the entered records in it.
    var s2 = sheet.getSheetByName('Users');//Get the sheet with the Allow list in it.
  
    var entryValues = s.getRange('C2:C9').getValues(); //(Get the list of e-mail addresses entered via the form (using their cell reference))
    var emailsAllowed = s2.getRange('A2:A6').getValues(); //(Get the list of allowed e-mail addresses (using their cell reference))
    var isAllowed = 0;
  
    for(var i = entryValues.length-1; i &gt; 1 ; i--)  // work from the bottom up so when you delete a row it will not miss other rows or delete a row it should not.
    {
      var valueE = entryValues[i] // Test Variable to see what the value is (Can delete this line)
      for(var t = 0; t &lt; emailsAllowed.length; t++) //Loop through all the records in the allow list
      {
        var valueA = emailsAllowed[t] // Test Variable to see what the value is (Can delete this line)
        if( entryValues[i] === emailsAllowed[t] ) // Check to see if there is a match between what was entered and what is in the allow list. //!!! For some reason this line is never true !!!//
        {  isAllowed = 1;} //if it is there set a variable isAllowed to 1 (to indicate that there is a match)
      }
  
      if( isAllowed === 1 ) 
      {isAllowed = 0; }// if there was a match set isAllowed back to 0, ready for the next run
      else
      {
        s.deleteRows(i) //if there was no match (and isAllowed is not set) delete the invalid row.
      }  
    }
  }
  </code></pre>
  
  <p>Thanks </p>
  
  <p><strong>UPDATE: This here is the working code:  Thanks to (Sandy Good)</strong></p>
  
  <pre><code>function onOpen() 
  {
  
    var sheet = SpreadsheetApp.getActiveSpreadsheet(); 
    var s = sheet.getSheetByName('Form1'); //Get the sheet with the entered records in it.
    var s2 = sheet.getSheetByName('Users');//Get the sheet with the Allow list in it.
  
    var entryValues = s.getRange('C2:C9').getValues().join().split(","); //(Get the list of e-mail addresses entered via the form (using their cell reference))
    var emailsAllowed = s2.getRange('A2:A6').getValues().join().split(","); //(Get the list of allowed e-mail addresses (using their cell reference))
  
    var isAllowed = 0; // Create the variable isAllowed and set it to 0 (this will be used to leave the row if it matches)
  
    for(var i = entryValues.length-1; i &gt; 1 ; i--)  // work from the bottom up so when you delete a row it will not miss other rows or delete a row it should not.
    {
      var valueE = entryValues[i] // Test Variable to see what the value is (Can delete this line)
      for(var t = 0; t &lt; emailsAllowed.length; t++) //Loop through all the records in the allow list
      {
        var valueA = emailsAllowed[t] // Test Variable to see what the value is (Can delete this line)
        if( entryValues[i] === emailsAllowed[t] ) // Check to see if there is a match between what was entered and what is in the allow list. //!!! For some reason this line is never true !!!//
        {  isAllowed = 1;} //if it is there set a variable isAllowed to 1 (to indicate that there is a match)
      }
  
      if( isAllowed === 1 ) 
      {isAllowed = 0; }// if there was a match set isAllowed back to 0, ready for the next run
      else
      {
        s.deleteRow(i+2) //if there was no match (and isAllowed is not set) delete the invalid row. (+ 2 because the rows start from 1 and they also have a heading (the the array starts from 0))
      }  
    }
  }
  </code></pre>