title: Email notification when changes are made to specific data in Google sheets
body: <p>I have a general script that will send email notification of changes made to a live roster in Google sheets and have set up a trigger for the event to occur 'On change'. All data in the sheet is retrieved via IMPORTRANGE. This script is performing as expected, however I wish to make a couple of changes that am not sure how to go about. Here is a sample sheet: <a href="https://docs.google.com/spreadsheets/d/1LjELgjsFjxIrqsk-ROEtRkOjL9987VtcCoc0A8X-8DE/edit?usp=sharing" rel="nofollow noreferrer">link to sheet</a></p>
  <ol>
  <li><p>Wish to only send email notification when changes concern the name 'Craig'. For example my name is either added or taken off a rostered day. The script currently sends emails for all changes made across the sheet.</p>
  </li>
  <li><p>ID the row that this change occurs so as to reference the date and venue in the email body.</p>
  </li>
  </ol>
  <p>Thanks for any help and suggestions.</p>
  <p>Full script:</p>
  <pre><code>function onEdit() {
  
      var getProps = PropertiesService.getUserProperties();
  
      var lenProp = getProps.getProperty('Len');
  
      var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Roster');
  
      var data = sheet.getRange('E4:ACB562').getValues().toString().length;
  
      if (data != lenProp) {
          getProps.setProperty('Len', data );
          MailApp.sendEmail('email@gmail.com', 'Changes have been made to your live roster', 'Previous value: ' + lenProp + ' New value: ' + data);
      }
  }
  </code></pre>
  <p>New revised script:</p>
  <pre><code>function installedOnEdit(e) {
    var range = e.range;
    var value = range.getValue();
    if (value == &quot;Craig&quot; || (e.oldValue == &quot;Craig&quot; &amp;&amp; value == &quot;&quot;)) {
      var rowNumber = range.getRow(); // You can retrieve the row number of the editor cell.
      console.log(rowNumber)
      var [colA, colB] = e.source.getActiveSheet().getRange(rowNumber, 1, 1, 2).getValues()[0];
  
      var getProps = PropertiesService.getUserProperties();
      var lenProp = getProps.getProperty('Len');
      var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Roster_LIVE');
      var data = sheet.getRange('E4:ACB562').getValues().toString().length;
      if (data != lenProp) {
        getProps.setProperty('Len', data);
        MailApp.sendEmail('email@gmail.com', 'Changes have been made to your roster!', 'Your live roster has been edited. These changes concern ' + colB + ' on ' + colA);
      }
    }
  }
  </code></pre>