[英]Generate a list of Sheets that meet a condition in Google Scripts?
I'd like to use Google App Script within Google Sheets to generate a list of sheet names that meet the condition of having a "Y" in a set cell across each sheet.我想在 Google Sheets 中使用 Google App Script 来生成一个工作表名称列表,该列表满足在每个工作表的一组单元格中有一个“Y”的条件。 A pseudocode example I thought about was:我想到的一个伪代码示例是:
>look through all sheets
>if cell "V2" on that sheet contains "Y", add the sheet's name to a list
>return the list
I just can't get my head around many of the functions in the App scripts.我只是无法理解 App 脚本中的许多功能。
function sheetNames() {
var ss=SpreadsheetApp.getActive();
var shts=ss.getSheets();
var sA=[];
for(var i=0;i<shts.length;i++) {
var sh=shts[i];
if(String(sh.getRange('V2').getValue()).indexOf('Y')>-1) {
sA.push(sh.getName());
}
}
return sA;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.