Reputation:
I am new to Google Sheet App Script and trying to to create a IF condition with it but receiving an error.
I want to populate This "Right"
result in Cell AO3
Your help will be appreciated
function myFunction() {
var sheet = SpreadsheetApp.getActive().getSheetByName('DATA')
var ss = sheet.getRange()
if(ss.getRange("i3").getValue()!=''
&&
ss.getRange("h3").getValue()!='')
{
console.log("Right!");
}
}
Upvotes: 0
Views: 54
Reputation: 27390
You didn't pass any parameters in the getRange()
method.
Even if you did the first part correctly, in your code, ss
is already a range object because you already used getRange(..)
. Therefore you can't use getRange(..).getRange('i3')
twice.
function myFunction() {
var ss = SpreadsheetApp.getActive().getSheetByName('DATA');
if(ss.getRange('i3').getValue()!='' && ss.getRange("h3").getValue()!='') {
console.log("Right!");
ss.getRange('ao3').setValue("Right!");
}
}
Upvotes: 1