【发布时间】:2021-10-20 01:13:16
【问题描述】:
根据我的问题,您会知道我是 Google 表格脚本的新手。 我正在创建一个宏以在特定列中的特定字符串下方插入一个单元格。例如,我需要在值为“Red”的单元格下方插入一个单元格。如果“红色”在 A5 中,那么我需要单元格 A6,而 A6 将在宏中多次使用。任何答案表示赞赏!
一切顺利!
【问题讨论】:
-
如何获得A6?非常感谢!
根据我的问题,您会知道我是 Google 表格脚本的新手。 我正在创建一个宏以在特定列中的特定字符串下方插入一个单元格。例如,我需要在值为“Red”的单元格下方插入一个单元格。如果“红色”在 A5 中,那么我需要单元格 A6,而 A6 将在宏中多次使用。任何答案表示赞赏!
一切顺利!
【问题讨论】:
function findRed() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName('Sheet1');
let f = sh.createTextFinder('Red').findAll();
let fA = f.map(r => { return {row: r.getRow(),col: r.getColumn()}} );
Logger.log(JSON.stringify(fA));
}
Execution log
11:12:41 AM Notice Execution started
11:12:41 AM Info [{"row":1,"col":1},{"row":4,"col":2},{"row":6,"col":4},{"row":8,"col":6},{"row":10,"col":8}]
11:12:42 AM Notice Execution completed
| Col1 | Col2 | Col3 | Col5 | Col5 | Col6 | Col7 | Col8 |
|---|---|---|---|---|---|---|---|
| Red | |||||||
| Red | |||||||
| Red | |||||||
| Red | |||||||
| Red |
【讨论】: