Google sheets script writing, how do I prevent an auto update or recacluation of my timestamps in googel sheets? -


i attached copy of spreadsheet run in google. concept when begins picking order, instance type name in i3 , time start. once complete type name in j3 , each causing time stamp below leading total duration time. later factor percentages.

the problem time stamps seem randomly update without prompting so. seems when printed or reopened. cause inaccuracies in times , percentages. assistance appreciated

it appear should write script accommodate need, haven't slightest on how this. directed forum reply in google docs forum

enter link description here

i don't think can choose on cell update or recalculate (tell me if i'm wrong).

a non-optimized workaround (maybe expert have got better solution):

function onedit(e){    var ss = spreadsheetapp.getactivespreadsheet();   var sheet = ss.getactivesheet();   var = 3;    while(i <= sheet.getlastrow())   {         var data = sheet.getrange(i, 9, 3, 2).getvalues();      if(data[1][0].length == 0)     {       if(data[0][0] != "")       {         var d = new date();         sheet.getrange(i+1, 9).setvalue(d);       }     }     if(data[1][1].length == 0)     {       if(data[0][1] != "")       {         var d = new date()         sheet.getrange(i+1, 10).setvalue(d);       }     }     i=i+3;   } } 

the onedit(e) function simple trigger implement in google spreadsheet. trigger each time cell edit.

on code above, iterate check on each element if name added or not. if so, code set date , time below name added. since set value on 1 single moment, no auto update modify time.

for workaround, need remove formula put on cell want timestamp (i.e i4 , j4). can keep cells calculate difference between time, should work no problem.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -