1 回答

TA贡献1829条经验 获得超4个赞
像这样重写函数:
function findValueInRange () {
var ss = SpreadsheetApp.getActiveSheet(),
theLastColumn = ss.getLastColumn(),
theLastRow = ss.getMaxRows();
if( theLastColumn>0) {
//Returns a two dimensional array of both rows and columns
var values = ss.getRange(1,1,theLastRow,theLastColumn).getValues();
var i=0,
rownum=0,
thisRow,
colvalue,
whatToFind = "testserial",
j=0;
for(i=0;i<values.length;i++) {
thisRow = values[i];
for (j=1;j<thisRow.length;j++) {
colvalue = thisRow[j];
if (colvalue === whatToFind) {
Logger.log("The string is in row: " + (i + 1) + " and column: " + (j+1));
}
}
}
}
}
添加回答
举报