Forum Discussion
ArchieSmith
Dec 22, 2022Copper Contributor
Office Script If Statement not working
Hi everyone! Apologies for my likely simple problem, I have little experience with coding but I'm trying my best to learn how to automate my Excel spreadsheets. My if statement doesn't seem t...
- Dec 22, 2022
After a bit of reading could you try the following:
function main(workbook: ExcelScript.Workbook) { let wsArr = workbook.getWorksheets(); wsArr.forEach(ws => { let range = ws.getRange("A4"); let rangeval = range.getValue(); if (rangeval == 'X') { console.log('Yes'); } else { console.log('No'); } } ) }
Lorenzo
Dec 22, 2022Silver Contributor
After a bit of reading could you try the following:
function main(workbook: ExcelScript.Workbook) {
let wsArr = workbook.getWorksheets();
wsArr.forEach(ws => {
let range = ws.getRange("A4");
let rangeval = range.getValue();
if (rangeval == 'X') {
console.log('Yes');
} else {
console.log('No');
}
}
)
}
ArchieSmith
Dec 22, 2022Copper Contributor
Thank you !
This works the intended way and will be a good place to start my attempt at automating.
This works the intended way and will be a good place to start my attempt at automating.
- LorenzoDec 22, 2022Silver Contributor
Welcome ArchieSmith & Thanks for providing feedback
+ Forgot to post: https://www.tutorialspoint.com/typescript/typescript_operators.htm