title: Min and Max row numbers for specific data range (cell value dependent)
body: <p>I have a form that is submitted and using the date stamp generates the month name for each submission. what i need is a method to generate the minimum and maximum row number for each months data. so if January submissions start on row 1 and end on row 13, feb starts on 14 and ends on 30 march starts on 31 and ends on 36. i need a script that will tell me those specific row numbers. i will then use those as a seperate data range to generate a month overview of each line within that range. </p>
  
  <p>below is what i have used so far but the results are not quite right: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function findCell() 
  {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheetByName('Votes');
    var lastRowSheet = sheet.getLastRow();
    var DataRange = "$B1:$B" + lastRowSheet.toString();
    var values = sheet.getRange(DataRange).getValues();
    Logger.log(values);
    
    var test = sheet.getRange('B4').getValue();
    Logger.log("test - " + test);
  
    for (var i = 0; i &lt; values.length; i++) 
      {
       var row = "";
       for (var j = 0; j &lt; values[i].length; j++) 
        {     
        if (values[i][j] == "May") 
          {
          row = values[i][j+1];
          //Logger.log(row);
          Logger.log(i+1);
          }
        }    
      };
  
    for (var rowMinApr= 0; rowMinApr&lt; values.length ; rowMinApr++ )
          {
          if (values[rowMinApr][0] == "April")
              {
              Logger.log("April min row - " + rowMinApr+1);
              break;
              }
          };
          
    for (var rowMaxApr= values.length -1 ; rowMaxApr&gt;= 0 ; rowMaxApr-- )
          {
            if (values[rowMaxApr][0] == "April")
              {
              Logger.log("April max row - " + rowMaxApr+1);
              break;
              }
          };
          
    for (var rowMinMay= 0; rowMinMay&lt; values.length ; rowMinMay++ )
          {
          if (values[rowMinMay][0] == "May")
              {
              Logger.log("Maymin row - " + rowMinMay+1);
              break;
              }
          };
          
    for (var rowMaxMay = values.length -1 ; rowMaxMay &gt;= 0 ; rowMaxMay-- )
          {
            if (values[rowMaxMay][0] == "May")
              {
              Logger.log("May max row - " + rowMaxMay+1);
              break;
              }
          };</code></pre>
  </div>
  </div>
  </p>
  
  <p>the log shows this:</p>
  
  <p><img src="https://i.stack.imgur.com/Zjjb6.png" alt="enter image description here"></p>
  
  <p>as you can see where it lists the row numbers where the cell value is April it is fine, but when i try the code to find the minimum and maximum rown numbers applicable to the relevant cell content it throws up some prett random numbers. currently the cells that have April in are rows 2 to 15 and May is rows 16 to 27.</p>