check rows for cell match in Google sheet Script

check rows for cell match in Google sheet Script

The following describes on how to check rows for cell match in Google Sheet Script
function onSearch() {

var ss1 = SpreadsheetApp.getActiveSpreadsheet();
var sheet1 = ss1.getSheetByName("Main Sheet"),
searchVal1 = sheet1.getRange("A1").getValue(),
searchCol1 = sheet1.getRange('A2:A').getValues();
for (var i = 0, len = searchCol1.length; i < len; i++) {
if (searchCol1[i][0] == searchVal1) {
sheet1.getRange(i + 1, 2).setValue("Matching")
}
}
}

About the author: Explore SARCS

You must be logged in to post a comment.