[英]Parse and count total sum of numbers - Google Apps Script
嘗試這個:
function myfunk1() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName('Your sheet name');
const sum = sh.getRange(2,2,sh.getLastRow() -2,1).getDisplayValues().reduce((a,c)=>{ a+=parseFloat(c);return a;},0);
sh.getRange(2,1,sh.getLastRow() - 1).getValues().forEach((r,i) => {if(r[0]=='sum')sh.getRange(i + 2,2).setValue(Number(sum).toFixed(2))});
}
輸出:
物品 | 成本 |
---|---|
1 | 57.9 |
2 | 111.9 |
3 | 39.9 |
和 | 209.7 |
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.