V
V
Vladimir Zuev2020-06-10 09:58:22
Google
Vladimir Zuev, 2020-06-10 09:58:22

How to limit the number of rows in a range to search for a word in a Google spreadsheet column?

How to limit the number of rows in a range to search for a word in a Google spreadsheet column?
Looking for a word in a table column using code like this

function check(sheetName, column, word) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName(sheetName);
  var range = sheet.getRange(column);
  var values = range.getValues();

  var result = false;
  for (var i = 0; i < values.length; i++) {
    if (values[i][0] == word) {
      result = i+1;
      break;
    }
  }
  return result;
}

The row range is taken as 1000 rows. Increasing the running time of the script. Whether it is possible to limit somehow a range on lines it is admissible through last.row?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question