, . . . .
, Put Sheet Tab Name Here , . searchString . , .
function findRowOfSearchString(searchString) {
var arrIndexOfAllMatches,dataAsStringWithBrackets,dataRange,i,
isThereA_Match,j,ll,L,L2,matchOfAllInnerBrackets,numberOfColumns,numberOfRows,
rowCutOff,rowsOfMatchedData,sh,sheetData,ss,thisIndex,thisMatchIndex,thisRow,thisRowData;
ll = function(a,b) {
Logger.log(a + ": " + b)
}
if (!searchString) {
searchString = "testSe";
}
ss = SpreadsheetApp.getActiveSpreadsheet();
sh = ss.getSheetByName('Put Sheet Tab Name Here');
dataRange = sh.getDataRange();
numberOfColumns = dataRange.getNumColumns();
numberOfRows = dataRange.getNumRows();
sheetData = dataRange.getValues();
dataAsStringWithBrackets = JSON.stringify(sheetData);
isThereA_Match = dataAsStringWithBrackets.indexOf(searchString);
if (isThereA_Match === -1) {return;}
arrIndexOfAllMatches = [];
L = dataAsStringWithBrackets.length;
thisMatchIndex = 0;
for (i=0;i<L;i++) {
thisMatchIndex = dataAsStringWithBrackets.indexOf(searchString,thisMatchIndex + 1);
if (thisMatchIndex === -1) {
break;
}
arrIndexOfAllMatches.push(thisMatchIndex);
}
matchOfAllInnerBrackets = [];
thisMatchIndex = 0;
for (i=0;i<L;i++){
thisMatchIndex = dataAsStringWithBrackets.indexOf("],[",thisMatchIndex + 1);
if (thisMatchIndex === -1) {
break;
}
matchOfAllInnerBrackets.push(thisMatchIndex);
}
ll('matchOfAllInnerBrackets',matchOfAllInnerBrackets)
rowsOfMatchedData = [];
L = arrIndexOfAllMatches.length;
L2 = matchOfAllInnerBrackets.length;
for (i=0;i<L;i++){
thisIndex = arrIndexOfAllMatches[i];
ll('thisIndex: ' ,thisIndex)
for (j=0;j<L2;j++){
rowCutOff = matchOfAllInnerBrackets[j];
ll('rowCutOff: ',rowCutOff)
if (rowCutOff > thisIndex) {
ll('greater than: ' ,thisIndex > rowCutOff)
thisRow = j+1;
ll('thisRow: ', (thisRow))
rowsOfMatchedData.push(thisRow)
break;
}
}
}
ll('rowsOfMatchedData: ',rowsOfMatchedData)
L = rowsOfMatchedData.length;
for (i=0;i<L;i++){
thisRowData = sh.getRange(rowsOfMatchedData[i], 1, 1, numberOfColumns).getValues();
ll('thisRowData: ',thisRowData)
}
}