Answer the question
In order to leave comments, you need to log in
Google app script search and highlight many words in a table?
I have a table in which, using a script, I need to find words from the list of stop words, and highlight them in the table. I found such a script, but it highlights only one word, although there are many similar words "Maria". Question: how to make it highlight all options, and how to add many words to the search +- 1000
function selectText(){
var ss = SpreadsheetApp.getActiveSpreadsheet() // SpreadsheetApp.openByUrl("URL на таблицу")
var sheet = ss.getActiveSheet() // ss.getSheetByName("Имя таблицы")
var text = "Мария" // тут должны быть все стоп-слова
var arrData = sheet.getDataRange().getDisplayValues() // sheet.getRange(1, 1, sheet.getLastRow(), sheet.getLastColumn())
for(var row = 0; row < arrData.length; row++){
for(var col = 0; col < arrData[0].length; col++){
if(arrData[row][col] == text){
sheet.getRange(row+1, col+1).setBackground("Red")
}
}
}
}
Answer the question
In order to leave comments, you need to log in
var text = ["Mary", "Mary1"] //Instead of a string, you need to make an array
if(text.includes(arrData[row][col])) //replace the condition with this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question