Answer the question
In order to leave comments, you need to log in
How to check if there is already a value in a column using Google Scripts?
Given a variable and a column in Google Sheets with values. You need to check the values in this column for matches with the variable, and if it is, return for example true. Tell me how to do it?
Answer the question
In order to leave comments, you need to log in
For example 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 = true;
break;
}
}
return result;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question