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
Hi ArchieSmith
I'm not an Office Script dev. + don't have access to the language with my subscription so no guarantee at all... What happens if you replace line #8 with:
if (rangeval = 'X'){
- ArchieSmithDec 22, 2022Copper Contributor
Hi Lorenzo
Unfortunately it does the same thing, 14 'yes'es.
It's an odd language that takes a lot from TypeScript and JavaScript from what I can work out.
Thanks for the help!