Excel Performance Problems

Improve Microsoft Excel Office Script Performance for Large Ranges

Ayan MasoodAyan Masood Nov 12, 2026 869 views

Question details

Improve the speed of an Excel Office Script that processes large worksheets by replacing cell-by-cell operations with a bulk range copy.

Improve Microsoft Excel Office Script Performance for Large Ranges
Product
Microsoft Excel Office Scripts
Device & OS
not provided
Scenario
The user needs to copy data from columns C through L on Sheet1 to the active worksheet while processing thousands of rows efficiently.
Observed behavior
Cell-by-cell reads and writes can make the script slow when the source range contains many rows.
Before you start

Confirm that Sheet1 exists and that columns C through L contain the data to copy. Decide whether the destination needs values only or whether formulas and formatting must also be retained.

Solution 1Recommended

Copy the used range in one Office Script operation

Use this method when copying a large contiguous range. A single range operation reduces the number of workbook calls and is much faster than processing each cell separately.

Office Scripts perform best when data is read, written, or copied in blocks. Get the used portion of the source range once, then copy it to the destination starting cell.

1
Open the Office Script editor

In Excel for the web, open the workbook and select the Automate tab, then select New Script or open the script you want to optimize.

2
Get the source used range

Use getWorksheet("Sheet1").getRange("C:L").getUsedRange() to target only the populated cells in columns C through L.

3
Copy the range to the active worksheet

Add the following bulk copy code: const selectedSheet = workbook.getActiveWorksheet(); const source = workbook.getWorksheet("Sheet1").getRange("C:L").getUsedRange(); selectedSheet.getRange("B1").copyFrom(source);

4
Run and verify the result

Select Run in the Automate pane, then check the active worksheet to confirm that the copied range begins at cell B1.

Copy the used range in one Office Script operation
Choose the appropriate copy type: copyFrom copies the source range in bulk. If your script must transfer values only, use the copy type option supported by your Office Scripts version, such as ExcelScript.RangeCopyType.values.
Free Microsoft Office alternative

Use WPS Spreadsheets for Efficient Large Excel Workbook Editing

Office Scripts are a Microsoft Excel for the web feature, so WPS Office does not run or troubleshoot those scripts. For everyday work with large Excel files, WPS Spreadsheets is a free, lightweight alternative with a familiar spreadsheet interface, strong format compatibility, and an easy migration path for existing workbooks.

Open, edit, and save Microsoft Excel .xlsx and .xls workbooks with high compatibility.Use efficient range-based copy, paste, fill, sort, and filter tools for large spreadsheet data.Work in a familiar spreadsheet interface designed for a smooth transition from Microsoft Excel.Free and lightweight for routine Excel workbook editing and data management.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my Office Script slow when it processes thousands of Excel rows?

Scripts can slow down when they repeatedly call getCell(), getValue(), or setValue() inside loops. Read, write, or copy a complete Range whenever possible to reduce workbook interactions.

How do I copy columns C through L without including empty rows?

Use workbook.getWorksheet("Sheet1").getRange("C:L").getUsedRange(). This returns the used part of those columns rather than the entire worksheet-column range.

Where does copyFrom place the copied Office Script data?

The destination is determined by the range before copyFrom. For example, selectedSheet.getRange("B1").copyFrom(source) places the source range with its top-left cell at B1 on the active worksheet.

Can Office Scripts copy values without copying formulas?

Yes. Use the bulk copy type for values when available, for example destination.copyFrom(source, ExcelScript.RangeCopyType.values). This transfers displayed values instead of formulas.

Should I use a loop to copy each cell in an Office Script?

Avoid per-cell loops for large transfers. Use copyFrom for a direct range copy, or retrieve values with getValues() and write them once with setValues() when you need to transform the data first.