title: search spreadsheet column for text in a string and return a result in another column
body: <p>Using google apps script and spreadsheet, I have been trying to do a simple thing but can't figure out the problem. I have a sheet, with a blank column and a column with text. The columns are not next to each other. I am trying to search for text in each cell in one column, and if the text is found, then set the value of the cell in the empty column as 'Yes'.</p>
  
  <p>Example (sorry no code - I've gone round and round with it for hours, and what I have is so convoluted, it's best to just provide an example):</p>
  
  <pre><code>Column A with text  Empty Column F
  abcd efg hij
  klmn opq rstu  
  vwxzy                  Yes
  </code></pre>
  
  <p>What is the simplest code to search Column A for 'xyz' and return a 'Yes' in Column F?</p>
  
  <p>I've looked at and tried about a dozen different code examples online, and can't get any of them work. Appreciate any help with this!!</p>
  
  <p><strong>EDIT</strong> (Final hopefully) for my use (I have some backend utilities that get me the column number based on the header name, that code not included in this, fyi):</p>
  
  <pre><code>var sskey = SpreadsheetApp.openById('**********************')
  
  function otherfunction(){
    addCustomValue('POCs', 'Groups', 'Champion', 'Champion', 'Yes');
  }
  
  function addCustomValue(sheetNamestr, searchColnamestr, writeColnamestr, searchKeystr, writeValstr) {
    var sheet = sskey.getSheetByName(sheetNamestr);
    var searchColnum = MyUtilities.getColIndexByName(sheet, 1, searchColnamestr);
    var writeColnum = MyUtilities.getColIndexByName(sheet, 1, writeColnamestr);
    var data = sheet.getDataRange().getValues();
    for (n=0; n&lt;data.length; ++n) {
      if (data[n][searchColnum-1].toString().match(searchKeystr)==searchKeystr){ data[n][writeColnum-1] = writeValstr};
      }
    sheet.getRange(1,1,data.length,data[0].length).setValues(data);
  }
  </code></pre>
  
  <p>Thanks Serge! Now I can run this over my spreadsheets based on any columns and conditions!</p>