How to Insert an Excel Worksheet Name into a Cell on the Web
Question details
Return and display the current worksheet's tab name dynamically in a specific cell while using Excel for the web.

- Product
- Excel for the Web
- Device & OS
- not provided
- Scenario
- A user needs to output the active worksheet tab name into a cell when working in the browser-based version of Excel.
- Observed behavior
- Standard desktop methods such as VBA macros and the CELL function with the "filename" argument are not supported and fail to work in the web environment.
Ensure you are signed into your Microsoft 365 commercial or educational account, as Office Scripts are required for this workaround and may not be available on personal accounts.
Use an Office Script to Write the Worksheet Name
Since VBA and certain formulas are restricted online, Office Scripts provide the most reliable native method to interact with and extract data in Excel for the web.
Office Scripts are a modern browser-based automation tool designed specifically for Excel on the web. They allow you to write lightweight TypeScript code to perform tasks that would traditionally require desktop VBA macros.
Navigate to the Automate tab on the ribbon in Excel for the web and click on New Script.
In the Code Editor panel, clear the default code and paste the following snippet to capture the sheet name: function main(workbook: ExcelScript.Workbook) { let sheet = workbook.getActiveWorksheet(); sheet.getRange("A1").setValue(sheet.getName()); }
Click the Save script button, then press Run to execute it. The current worksheet name will immediately populate in cell A1.

Use WPS Office to Extract Worksheet Names Using Standard Formulas
If you find web limitations frustrating, WPS Office offers a free and highly compatible desktop alternative. WPS Spreadsheet fully supports standard desktop features like the CELL function and VBA macros, letting you automate tasks without needing to write custom web scripts.
- 1. Download WPS Office: Install the free WPS Office suite on your computer.
- 2. Open Your Spreadsheet: Launch WPS Spreadsheet and open your existing Excel file.
- 3. Apply the CELL Formula: Select your target cell and input: =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
- 4. View the Result: Press Enter, and the worksheet name will instantly appear without needing to write or run manual scripts.

Frequently Asked Questions
Why doesn't the CELL function work in Excel for the web?
The CELL function relies on local system file paths to return the filename and worksheet. Since Excel for the web operates in a secure browser environment without access to a local file directory, the "filename" argument is completely unsupported.
Are Office Scripts available for all Excel web users?
No, Office Scripts are currently only available to users with qualifying Microsoft 365 commercial or educational licenses. If you are using a free personal account, you will not have access to the Automate tab.
Can I use VBA macros in the web version of Excel?
VBA macros are designed strictly for desktop versions of Excel and cannot run in a browser environment. You must use Office Scripts as the designated automation alternative for Excel on the web.




