I recently created a script for a Google Sheet that involves taking user input and comparing it to values already on the spreadsheet.
Within the function below, I captured the user's desired number using the variable voltReqed
.
My goal is to compare this value (checking if it is less than or greater than) with each number in an array generated by the variable voltCompareData
.
As I am still learning about scripts, I appreciate your understanding of any mistakes I may make.
function getVoltage() {
var voltReqed = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2").getRange("A1").getValue();
Logger.log(voltReqed);
var voltCompareData = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SpecsList").getSheetValues(3, 2, 1, 3);
Logger.log(voltCompareData);
var voltSample1 = voltCompareData.getValue(1,1);
Logger.log(voltSample1);
}
The variable voltSample1
was my attempt at extracting the first number from the array produced by the voltCompareData
variable for comparison purposes.
Please refer to the image for the specific number and array obtained and recorded through the aforementioned script.