I want to check if a substring is in a string.
The string come from the 12th row of a Google sheet. The substring come from an HTML form where the user inserts data. (It's a simple string in the example below and it still doesn't work. The problem is not the data inserted.)
I want to display the row number of the string when the substring is detected.
for (var i=0; i < sheetDataRange.getValues().length; i++) {
if (sheetDataRange.getValues()[i][11].includes("I14")) { // The string value is okay
SpreadsheetApp.getUi().alert(i+5); // The data starts at the 5th row
}
}
I tried to resolve the issue with the includes() function. The issue is that some rows without "I14" are displayed and other with it are not. I tried to use the match() function too but it doesn't work.
Thanks for your help.
getValues()[i][11is 12th column not a row. And actually you're using terribly wrong the methodgetValues(). Try @Cooper's solution.