Select multiple sheets in Excel using Applescript
I have an Excel workbook with multiple worksheets.
I need to copy 2 of the sheets (Report1 and DataX) out to a new workbook.
Report1 has formulas referencing to DataX, and also formulas referencing to other sheets.
The requirement is, for formulas referencing to other sheets, I will break link after copying them to the new workbook. However, the links in Report1 to DataX are to stay.
Tried the following:
--define path of file
tell application "Finder"
set workdir to (get folder of (path to me)) as Unicode text
end tel
set master to Master.xlsx
tell application "Microsoft Excel"
set theSheets to {sheet "Report1" of workbook master, sheet DataX of workbook master}
set outputFile to make new workbook
set display alerts to false
copy worksheet theSheets before sheet "Sheet1" of outputFile --copy the 2 sheets out to new file
tell active workbook
break link name workdir & master type link type Excel links
end tell
end tell
The above does not work because the links in Report1 for DataX were referenced to the original file instead of the new workbook. And after breaking link, the data became static.
How can I do it such that the referencing moves together with the copied sheets?
MacBook Pro with Retina display, OS X Yosemite (10.10.4)