Hi @Rolf Beck - when comparing values, you should use either the double or triple equals sign rather than the singular. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness
Hopefully that helps!
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello
I am new to office script and would like to program a simple condition:
If the cell C6 contains the value 1, the value 2 should be inserted. If the cell C6 contains the value 2, the value 1 should be inserted. So every time the script is executed, the value of C6 changes between 1 and 2.
I have tried it this way, but the value does not change as desired. It seems that the "else" statement is not executed:
let myvalue = "C6";
if (myvalue = "1") {
selectedSheet.getRange("C6").setValue("2");
} else {
selectedSheet.getRange("C6").setValue("1");
}
Hi @Rolf Beck - when comparing values, you should use either the double or triple equals sign rather than the singular. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness
Hopefully that helps!