Excel Office Script to Copy a Cell Between Worksheets
Question details
The user needs to copy a value from one worksheet cell to another by using an Excel Office Script instead of VBA.
- Product
- Microsoft Excel Office Scripts
- Device & OS
- not provided
- Scenario
- Transfer the value in Sheet1!A1 to Sheet2!E1 and optionally run the script from a button or Power Automate.
- Observed behavior
- The desired result is for the destination cell to receive the source value; Office Scripts cannot directly write to the system clipboard.
Confirm that the worksheet names and cell references are correct, and verify that Office Scripts are available in your Excel account. Decide whether the script should run manually from Excel, from a worksheet button, or through Power Automate.
Use an Office Script to copy the value between worksheets
Use this solution when you need to transfer a cell value programmatically without relying on VBA or the system clipboard.
The script reads the value from Sheet1 cell A1 and writes it to Sheet2 cell E1. Change the worksheet names and ranges to match your workbook.
This transfers the cell value only. It does not copy formatting, formulas, or clipboard contents.
Open the workbook in Excel for the web or a supported Microsoft 365 Excel version, then select the Automate tab and choose New Script.
Delete the generated code and enter: function main(workbook: ExcelScript.Workbook) { const source = workbook.getWorksheet("Sheet1").getRange("A1").getValue(); workbook.getWorksheet("Sheet2").getRange("E1").setValue(source); }
Select Save script, then click Run in the Office Scripts pane. Check Sheet2 cell E1 to confirm that it contains the value from Sheet1 cell A1.
To make the script easier to launch, use the script's More options menu to add it to a workbook button when available, or connect the script to a Power Automate flow.
Use a worksheet reference for a simple, non-script transfer
Use this option when the destination should stay linked to the source value and no button or automation is required.
Edit and link worksheet values with WPS Office
WPS Office is a free, lightweight Microsoft Office alternative for opening and editing Excel workbooks. Its familiar spreadsheet interface supports worksheet references, formulas, and common workbook formats, making it easy to migrate a simple cell-transfer workflow without learning a new layout.
- 1. Open the workbook in WPS Spreadsheet: Launch WPS Office, choose Spreadsheet, and open the Excel workbook containing the source and destination worksheets.
- 2. Create the worksheet link: Select the destination cell, enter a reference such as =Sheet1!A1 in the formula bar, and press Enter to display the source value.
- 3. Save in an Excel-compatible format: Use Menu > Save As, select Excel Workbook (*.xlsx) or another required Microsoft Excel format, and save the edited file.

Frequently Asked Questions
Can an Excel Office Script copy a value from one worksheet to another?
Yes. Use workbook.getWorksheet to access each sheet, getRange("A1").getValue() to read the source, and setValue(source) on the destination range, such as Sheet2!E1.
How do I change which cells the Office Script copies?
Replace the worksheet names and range addresses in the script. For example, change Sheet1 and A1 to the source sheet and cell, then change Sheet2 and E1 to the destination.
Can Office Scripts copy formatting along with the cell value?
The example only transfers the value. To copy formatting, use range formatting APIs separately, or use copyFrom with the appropriate copy type when supported by your Excel version.
Can I connect the Office Script to a button?
In supported Excel environments, open the script's More options menu and choose the option to associate or add the script to a workbook button. You can also run it through a Power Automate flow.
Why does the script not copy data to my computer clipboard?
Office Scripts do not directly control the system clipboard. They can read and write workbook ranges, so write the value to a destination cell or use a separate manual copy action when clipboard data is needed.




