Thanks for reporting this issue! I believe this has the same root cause as the issue we're currently investigating on this thread: https://learn.microsoft.com/en-us/answers/questions/1295289/broken-excel-script-please-help-me-troubleshoot
In short, certain scripts are failing on recent builds of Excel for Windows. The Office Scripts team is working on a fix; in the meantime, you can try to run your script in the browser instead. We apologize for the inconvenience!