function myFunction() { x=0; for(s=1;s<101;s++){ if(Math.random()<0.5)x=x+1; } id="1qQqILcSpfpTL1ayVWuID3PfVkm0FdoIvtip69lKrLvE"; ex = SpreadsheetApp.openById(id); var sheet = ex.getSheetByName("data"); sheet.getRange(4,4).setValue(x); }