I'm a beginner with Google Apps Script and I'm working on creating a script for a spreadsheet where I need to retrieve the range for a matched value. Unfortunately, there doesn't seem to be a function like .getRow()
or .getRange()
that can be used directly since the value is in string format. Below are the codes I have written:
function getInfo() {
var ss1 = sheet1.getSheetByName("Sheet1");
var ss2 = sheet2.getSheetByName("Rates");
var getCountry = ss1.getRange(ss1.getLastRow(), 11).getValue();
var countryRange = ss2.getRange(2, 1, ss2.getLastRow(), 1).getValues();
var getZone = 0;
for (var i = 0; i < countryRange.length; i++) {
if (countryRange[i] == getCountry) {
var getrow_cr = countryRange[i].getRow(); //.getRow() cannot be applied here as it's a string value
getZone = ss2.getRange(getrow_cr + 1, 2).getValue();
}
}
Logger.log(getZone);
}
Can anyone help me figure out how to determine the row containing the matched string so I can retrieve the cell value next to it?