title: Google Scripts Search & Return Cell Location
body: <p>I am having some trouble with my first Google Script and would appreciate some help.</p>
  
  <p>Objective: To search multiple sheets for a value and then return the location of the cell if a match was found.</p>
  
  <p>I have tried using this script:</p>
  
  <pre><code>/**
  * Finds a value within a given range. 
  * @param value The value to find.
  * @param range The range to search in.
  * @return A range pointing to the first cell containing the value, 
  *     or null if not found.
  */
  function find(value, range) {
  var data = range.getValues();
  for (var i = 0; i &lt; data.length; i++) {
  for (var j = 0; j &lt; data[i].length; j++) {
  if (data[i][j] == value) {
  return range.getCell(i + 1, j + 1);
  }
  }
  }
  return null;
  }
  </code></pre>
  
  <p>However it returns the error "TypeError: Cannot find function getValues in object "</p>
  
  <p>My value will be defined as a text string e.g "ABCD"</p>
  
  <p>My range will be ranges of multiple sheets e.g sheet1!A1:C4,sheet2!A1:C4</p>
  
  <p>The function should return the sheet, column and row of the lookup value</p>
  
  <p>Currently i'm using an iferror index match loop formula to search sheets one column at a time (I'm using indirect as my range is variable) but would like a script to make this easier and faster.</p>
  
  <pre><code>=IFERROR(index(INDIRECT(Sheet1!A:A),
  iferror(MATCH(A2,INDIRECT(Sheet1!B:B),0),
  iferror(MATCH(A2,INDIRECT(Sheet1!C:C),0),
  ...ETC
  </code></pre>
  
  <p>Thank you in advance for any help.</p>