Created
March 14, 2019 14:33
-
-
Save rodrigomojeda/b798a2f287990f786e4d079058d5f5cd to your computer and use it in GitHub Desktop.
Searches for a string in a Google Sheets sheet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Searches for a string in a sheet*/ | |
function searchString(stringToSearch,sheetName) { | |
var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName); | |
var selection=sheet.getDataRange(); | |
var columns=selection.getNumColumns(); | |
var columnsnames = selection.getColumn() | |
var rows=selection.getNumRows(); | |
for (var column=1; column < columns; column++) { | |
for (var row=1; row < rows; row++) { | |
var cell=selection.getCell(row,column); | |
if (cell.getValue() == stringToSearch ) { | |
return true; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment