我需要宏只应用于一系列单元格

问题描述 投票:0回答:1

我需要宏作为参考 var targetRange =targetSheet.getRange(targetSheet.getLastRow()+1,1);但仅来自一系列单元格,从 1 到 7。 因为我需要在宏给我带来的数据前面写 使用 getLastRow()+1 时,它会获取我在工作表中写的所有内容并继续复制相同的信息。

我喜欢应用程序脚本,但我需要更多帮助

google-apps-script google-sheets macros range getlasterror
1个回答
0
投票
A C D E F G H J
1 COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10
2 1 8 1 1 5 2 3 0 0 1
3 10 9 8 2 3 6 5 7 3 6
4 9 8 8 2 8 1 4 4 9 8
function getvaluesfromARangeofCells() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName("Sheet1");
  const [[a1,,,,,,,,,],[,b2,,,,,,,,],[,,c3,,,,,,],[,,,d4,,,,,]] = sh.getDataRange().getValues();
  Logger.log("a1: %s, b2:%s, c3:%s, d4: %s",a1,b2,c3,d4);
}

xecution log
5:06:07 PM  Notice  Execution started
5:05:58 PM  Info    a1: COL1, b2:8.0, c3:8.0, d4: 2.0
5:06:10 PM  Notice  Execution completed
© www.soinside.com 2019 - 2024. All rights reserved.