title: Loop through a range of cells Google Sheets
body: <p>First of all, I'm new to coding - so the script that I have I combined it from a couple different scripts and it seems to work, but I would like to simplify it. </p>
  
  <p>I have such a script: </p>
  
  <blockquote>
    <p>function count() {</p>
  
  <pre><code>  var Month = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Private').getRange('A2').getValues();
      var PCC = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Private').getRange('B1').getValues();
      var PCCQ = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(Month).getRange(PCC);
      var PCCS = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(Month).getRange('B4').getValue();
      var PhoneCC = GmailApp.search(PCCS);
  </code></pre>
    
    <p>PCCQ.setValue(PhoneCC.length);</p>
  </blockquote>
  
  <p>}</p>
  
  <p>What it does:</p>
  
  <ol>
  <li>it takes the name of the sheet where I want the results from cell <strong>A2</strong> of sheet Private. </li>
  <li>it takes the cell where I want the result from cell <strong>B1</strong> of sheet Private. </li>
  <li>we get the range by combining the sheet name in <strong>1</strong> and cell from <strong>2</strong></li>
  <li>it takes the query that we need from the sheet that get from <strong>1</strong> and cell <strong>B4</strong></li>
  <li>makes a search in Gmail with the query from <strong>4</strong></li>
  <li>sets the value of the cell from point <strong>3</strong> as the length of the search from point <strong>5</strong></li>
  </ol>
  
  <p>However I have a range of cells for point <strong>2</strong> that I need this to work through, let's say <strong>B1:B70</strong>.</p>
  
  <p>Is there a way to adjust this script to do this? </p>
  
  <p>Will be very thankful.</p>