title: How can you set the value of a target cell in google sheets within a forEach loop in google apps script?
body: <p>I've written a script that searches through a sheet, finds rows that meet 7 parameters, returns those rows' data, and sends an email to the address in each of the matching rows. As part of this process, I want to update the cell value for 'Date of last contact' to the date the email is sent (that part's not hard). I'm struggling to get the A1 notation of the cell containing the date of last contact, which I believe I need in order to use the setValue() method. Here's the relevant parts of the code:</p>
  <pre><code>function sendFollowUps () {
    // Gets data from defined range of active sheet
    var rows = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Test List').getRange(2,1,152,12).getValues()
  
    // User-defined cutoff date, everything on or before will be contacted
    var cutoffDate = new Date('11/10/2021')
    console.log('Cutoff date is: ' + cutoffDate)
  
    // selects and returns only firms that haven't been met, schedule, or declined and have a date of last contact on or before the cutoffDate
    var filteredRows = rows.filter(function(row) {
      if (row[10] &amp;&amp; row[10] != 'Met' &amp;&amp; row[10] != 'Responded' &amp;&amp; row[10] != 'Warm' &amp;&amp; row[10] != 'Scheduled' &amp;&amp; row[10] != 'Declined' &amp;&amp; row[11] &lt;= cutoffDate) {
        return row
      }
    })
  
    // for each firm returned by filteredRows, pulls email, firstName of investor, and firmName
    filteredRows.forEach(function(row) {
      var email = row[6]
      var firstName = row[4].split(' ')[0]
      var firmName = row[0]
      var sendToEmails = ['...']
  
      // Customized email message with firstName, firmName updated per investor
      var messageSubject = '...'
      var messageBody = `...`
  
      // Adds investor email to recipient list
      sendToEmails.push(email)
  
      // Formats recipient list to CSV string
      sendToEmails.join(',')
  
      // Sends email with customized firstName and firmName to email in row
      GmailApp.sendEmail(sendToEmails, messageSubject, messageBody, {'from': 'me@email.com'})
  
      followUpEmails.push(email)
  }
  </code></pre>
  <p>I've tried just setting <code>row[11] = sendDate</code> within the forEach loop, but that doesn't actually update the cell value in the sheet. I've also tried using <code>SpreadsheetApp.getSheetByName('Test List').getRange(row[11])</code>, <code>SpreadsheetApp.getSheetByName('Test List').getActiveCell()</code>, and <code>SpreadsheetApp.getSheetByName('Test List').getCurrentCell(row[11])</code>, no joy with those either.</p>
  <p>How can I go about getting the A1 notation for the row[11] cell in order to use setValue method?</p>