title: 'For loop' that increments based on minute time trigger as custom timer
body: <p>I am not really that good at anything to do with computers generally and tried to create a timer in VBA and on running into roadblocks there (macros would lose functionality when shared) I tried creating the same thing now using Google Sheets, so that it becomes easier to work with shared sheets, but now have a different set of problems:  </p>
  
  <p>1) My timer is not actually a timer but just a 'for loop' that increments based on minute time trigger and hence the more cells the slower each subsequent cell timer.  </p>
  
  <p>2) When the cell timers run for a while the timer automatically stops and gives me the error message:  </p>
  
  <blockquote>
    <p>Service using too much computer time for one day  </p>
  </blockquote>
  
  <p>or sometimes  </p>
  
  <blockquote>
    <p>exceeded maximum execution time  </p>
  </blockquote>
  
  <p>and then I have to manually trigger the timer or wait for the minute time trigger to fire again which would render this sheet useless.  </p>
  
  <p>I am pasting the code below if anyone out there would care to help this old timer:</p>
  
  <p><strong>makelist()</strong> Stores Cell Locations on Another Sheet for the cells that call this function using a Startbutton</p>
  
  <pre><code>function makelist() {
   var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
   var cell = ss.getActiveCell();
   var r = cell.getRow();
   var c = cell.getColumn();
   var list = SpreadsheetApp.getActiveSpreadsheet().getSheets()[1];
   var i = 1;
   var cell=list.getRange(1,1);
   while( cell.getValue()!= ""){
    i++;
   cell=list.getRange(i,1);
   }
   cell.setValue(r);
   cell=list.getRange(i,2);
   cell.setValue(c);
   }
  </code></pre>
  
  <p><strong>dellist()</strong> deletes particular cell locations on which the StopButton has been pressed from the list .  </p>
  
  <pre><code>function dellist(){
    var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    var cell = ss.getActiveCell();
    var r = cell.getRow();
    var c = cell.getColumn();
    var list = SpreadsheetApp.getActiveSpreadsheet().getSheets()[1];
    var i = 1;
    var cell1=list.getRange(1,1);
    var cell2=list.getRange(1,2);
   while( cell1.getValue() != ""){
    if(cell1.getValue() == r &amp;&amp; cell2.getValue() == c){
    list.deleteRow(i);
    }
    i++;
    cell1=list.getRange(i,1);
    cell2=list.getRange(i,2)
    }
    }
  </code></pre>
  
  <p><strong>addtime()</strong> Increments Active Cells Values by 1 for all cells whose locations are stored in the list.</p>
  
  <pre><code>function addtime(){
   var s1=SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
   var s2=SpreadsheetApp.getActiveSpreadsheet().getSheets()[1];
   var r,c,value,n;
   for(n=1;n&lt;=60;n++)
   { 
    var i=1;
    var cell=s2.getRange(1,1);
    var cell1=s2.getRange(1,2); 
  
  while(cell.getValue()!="")
   {
  
   r=cell.getValue();
   c=cell1.getValue();
   cell3=s1.getRange(r,c);
   value=cell3.getValue();
   cell3.setValue(value+1);
   i++;
   cell=s2.getRange(i,1);
   cell1=s2.getRange(i,2);
   }
   }    
   }
  </code></pre>