【问题标题】:Sum the same cell from multiple sheets in Google Sheets将 Google 表格中多张表格中的相同单元格相加
【发布时间】:2021-11-15 01:56:45
【问题描述】:

在 Google 表格中对表格中的同一单元格求和的理想脚本是什么? 例如,我需要将五十个渐进纸的 A1 单元格相加 =sum(‘Sheet0’!A1 + ‘Sheet2’!A1 + ‘Sheet’!A1 and so on) 而且我想比写每个工作表名称以及在excel中更有效地做到这一点 =sum(Sheet0:Sheet50!A1)

【问题讨论】:

    标签: google-apps-script google-sheets google-sheets-formula


    【解决方案1】:

    匹配表的总和 A1

    function sheetcellsum() {
      const ss = SpreadsheetApp.getActive();
      let sum = 0;
      ss.getSheets().forEach(sh => {
        if(sh.getName().match(/Sheet\d+/)) {
          sum += sh.getRange('A1').getValue();
        }
      });
      //Logger.log(sum);
      return sum;
    }
    

    getSheets()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-16
      • 2021-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多