title: Looping Through Two Cells To Find Matches, And then Copying Range When There's A Match
body: <p>I'm trying to write a google app sctipt that loops through to ranges of dates to find matches, and for every match it finds, it copies specified range of "expenses" into a specified range. When I run the script, it executes, but nothing happens. It exceed execution time limit so I think it's getting stuck in a loop.</p>
  
  <p>UPDATE: I've created a test worksheet if anyone would like to see an example of the data involved: <a href="https://docs.google.com/spreadsheets/d/1J9L5b3UMCJGZV8QiUu9RyVrmaDVaK7FroLN8aDLYwxs/edit?usp=sharing" rel="nofollow">https://docs.google.com/spreadsheets/d/1J9L5b3UMCJGZV8QiUu9RyVrmaDVaK7FroLN8aDLYwxs/edit?usp=sharing</a></p>
  
  <p>Here is my code: </p>
  
  <pre><code>function menuItem1() {
   var sheet = SpreadsheetApp.getActiveSheet();
  
    //Updating Expenses 2
    for(row = 10; row &lt;= 61; row++){
      var date1 = sheet.getRange(row, 3, 1);
      var date1value = date1.getValue();
  
      for(row2 = 22; row2 &lt; 59; row++){
        var date2 = sheet.getRange(row2, 18, 1);
        var date2value = date2.getValue();
  
  
        if(date1value == date2value){
          sheet.getRange(row2, 19, 2, 8).copyTo(sheet.getRange(row1, 5, 8), {contentsOnly:true});
        }
      }
  </code></pre>
  
  <p>If anyone could help in anyway to figure out what the issue is, it would be greatly appreciated! Thanks!</p>