Office Settings & Configuration

Select and Zoom to a Range in Excel for the Web with Office Scripts

Huma Ashraf ChHuma Ashraf Ch Nov 18, 2026 868 views

Question details

The user wants to select a range and zoom to it using Office Scripts in Excel for the web.

Select and Zoom to a Range in Excel for the Web with Office Scripts
Product
Microsoft Excel for the web and Office Scripts
Device & OS
not provided
Scenario
Reproduce Excel's Select and Zoom commands for a specified range in a web-based workbook.
Observed behavior
Office Scripts can select a range, but it has no direct equivalent to ActiveWindow.Zoom or a command to zoom to the selected range.
Before you start

Open the workbook in Excel for the web and identify the worksheet and range you want to select. Check that the Automate tab is available so you can create and run an Office Script.

Solution 1Recommended

Select the range with an Office Script and adjust zoom manually

Use this approach when you need a script to select a range, followed by a manual zoom adjustment.

Office Scripts can select cells, but it does not expose an equivalent to VBA's ActiveWindow.Zoom or a command that automatically fits the selected range to the window.

1
Open the script editor

In Excel for the web, open the workbook and choose Automate > New Script.

2
Add the range selection

Replace the editor contents with: function main(workbook: ExcelScript.Workbook) { const worksheet = workbook.getActiveWorksheet(); worksheet.getRange("F6:L15").select(); } Change F6:L15 to the range you need.

3
Run the script

Activate the intended worksheet, then click Run in the script editor. The script selects the specified range on that worksheet.

4
Adjust the view

Use Excel's zoom controls if available, or open your browser's menu and adjust Zoom until the selected range is easy to see. Browser zoom changes the whole page and does not automatically fit the selection.

Select the range with an Office Script and adjust zoom manually
Automatic zoom is not available: Selecting the range does not change the zoom level. The zoom adjustment must be made separately.
Free Microsoft Office alternative

View Excel Workbooks in WPS Spreadsheet

WPS Office is a free, lightweight Office alternative with a familiar spreadsheet interface and Microsoft Excel format compatibility, making it easy to move existing workbooks. It does not run or fix Microsoft Office Scripts.

Open and edit Excel workbooks in XLSX formatSelect spreadsheet ranges and adjust the view manuallyUse a familiar interface for a smoother move from Microsoft OfficeWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Can Office Scripts zoom to the selected range?

No. Office Scripts can select a range with getRange(...).select(), but it does not provide a command to zoom the view to that selection.

How do I select a range on a specific worksheet?

In Automate > New Script, use workbook.getWorksheet("Sheet1").getRange("F6:L15").select(), replacing the sheet name and range with your own.

How can I change the zoom in Excel for the web?

Use Excel's zoom controls if they are available, or adjust Zoom from your browser menu. Browser zoom affects the entire page rather than fitting only the selected cells.

Will an Office Script run in WPS Spreadsheet?

No. Office Scripts are a Microsoft Excel feature. WPS Spreadsheet can open XLSX workbooks, but it does not run Office Scripts.