Forum Discussion
Office Scripts - Working With Multiple Worksheets
- Jul 27, 2021
I figured this out... all you have to do is declare a different variable name for the next workbook. In the first block of code, which is in my original message, the variable is called "selectedsheet" and the statement looks like this: "let selectedSheet = workbook.getWorksheet("Issues");"
What I did for the next worksheet is this: "let sheetproblems = workbook.getWorksheet("problems")" and followed up with the rest of the items.The way I figured this out was to open a new Excel sheet and actually record a new script by bolding the text in cells on two separate worksheets. Then I just looked at the code that was automatically generated to see how it handled switching worksheets.
I hope someone finds this information useful in the future.
I figured this out... all you have to do is declare a different variable name for the next workbook. In the first block of code, which is in my original message, the variable is called "selectedsheet" and the statement looks like this: "let selectedSheet = workbook.getWorksheet("Issues");"
What I did for the next worksheet is this: "let sheetproblems = workbook.getWorksheet("problems")" and followed up with the rest of the items.
The way I figured this out was to open a new Excel sheet and actually record a new script by bolding the text in cells on two separate worksheets. Then I just looked at the code that was automatically generated to see how it handled switching worksheets.
I hope someone finds this information useful in the future.
Thanks for your reviewSargentSynergy. I´ve had the same issue and your response helps me lot 🙂 .