How to Fix Office Scripts Not Copying Formulas in Excel Worksheets
Question details
The user needs to know how to resolve an issue where an Office Script fails to copy formulas across Excel worksheets or tables.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Executing an Office Script to copy data between worksheets, particularly when rows contain formulas, blank cells, hidden columns, or specific formatting.
- Observed behavior
- The Office Script copies only the static values, stripping away the underlying formulas and calculations during the paste operation.
Review your Office Script code to identify the exact functions handling the copy-paste operation, and ensure you have a sample dataset ready to reproduce the issue.
Seek Specialized Code Support on Stack Overflow
Because Office Scripts require specific TypeScript coding expertise, posting your code to a developer community like Stack Overflow is the most effective way to get a tailored fix.
Microsoft's Office Scripts operate using specialized TypeScript/JavaScript APIs. When default methods fail to carry over formulas, or when dealing with complex ranges involving hidden columns and blank cells, custom code adjustments are usually required.
Create a minimal, safe version of your Excel workbook that contains the table structure, formulas, and any blank or hidden columns relevant to your issue.
Open the Code Editor in Excel, highlight your entire TypeScript or JavaScript code, and copy it to your clipboard.
Go to Stack Overflow and write a concise title. In the body, explain exactly how formulas, filters, hidden columns, and formatting should be handled, and state that the script currently pastes values instead.
Tag your question with 'excel', 'office-scripts', and 'typescript' to ensure it reaches developers who are experts in this specific Microsoft ecosystem.

Experience Seamless Formula Handling with WPS Office
If Microsoft Excel's Office Scripts are proving too complex for your automation needs, consider WPS Office. It is a powerful, lightweight alternative that handles cross-sheet formula copying flawlessly without requiring advanced coding skills.
- 1. Download the Installer: Visit the official WPS Office website and click on the 'Download WPS Office Free' button.
- 2. Install WPS Office: Run the downloaded installation file and follow the straightforward on-screen instructions.
- 3. Open Your Workbooks: Launch WPS Spreadsheets, open your existing .xlsx files, and effortlessly manage your formulas and data.

Frequently Asked Questions
Why does my Excel Office Script only paste values by default?
Many default range copy methods in Office Scripts are designed to extract only the static values to optimize performance. To copy formulas, you typically need to specify parameters like RangeCopyType.formulas when using the copyFrom method.
How do hidden columns or filters affect copying in Office Scripts?
Hidden columns or filtered rows can disrupt standard script operations. Unless explicitly coded to bypass or include hidden cells (for example, by targeting only visible cells), the script might read data incorrectly, resulting in misaligned pastes.
Can I use VBA instead of Office Scripts to copy formulas?
Yes, VBA is widely used in desktop versions of Excel to automate tasks, including copying formulas. However, Office Scripts are specifically designed for Excel on the Web and cross-platform automation where VBA is not supported.




