workbook and sheet name via formula


I have a standard header I put on almost every excel workbook I create I have been using for years. It includes several standard items, including Workbook name and Worksheet name, which are extracted via CELL("Filename",A1) formula. 


For Excel workbooks that are being viewed in Excel Online, however, whether through onedrive, sharepoint, or whatever, this formula yields a #VALUE! error. When I open in desktop, it renders fine, just not when looking at browser window. 


Is there an alternative that I can use to display current workbook and worksheet names via a formula in a cell that is compatible with Excel Online?

10 Replies


you need to create a Name like "SheetName" and use GET.CELL(32,A1) in the Refers To area. Whenever you need the sheet name you need to type "=SheetName" in the cell and you will get workbook and sheet name. 


This is a Excel 4 Macro and not being supported. You can use it in Names though.

Best Response confirmed by liverlarson (Contributor)


Afraid for Excel Online that's only with Office Script, there are properties getName both for workbook and worksheet.


VBA and related functions don't work in Excel Online.




Read out the designation / name of the worksheet

Read out by formula

The focus of the formula solution is the CELL function (infotype; reference). In addition to the file name and the full path, the File Name infotype also returns the name of the worksheet. This is extracted using further functions so that only the sheet name is output at the end.

The result is achieved with these two formulas:
(formulas are from German Translate)
a) = PART (CELL ("filename"; A1); FIND ("]"; CELL ("filename"; A1)) + 1; 255)


b) = PART (CELL ("filename"; A1); FIND ("]"; CELL ("filename"; A1)) + 1; LENGTH (CELL ("filename"; A1)) - FIND ("]"; CELL ("filename"; A1)))

2. Read out via VBA

The following VBA function reads out the sheet name via VBA and displays it in a cell. To do this, enter the following code in a code module.


Public Function sheetname () As String
sheetname = ActiveSheet.Name
End function


If you now enter the function = sheetname () in a cell, the sheet name is read out and output in the corresponding cell.



I would be happy to know if I could help.



I know I don't know anything (Socrates)


* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.


@Nikolino , VBA doesn't work with Excel Online

You are right, I disregarded the labels

@Sergei Baklan Hmm, wasn't aware of office scripts. From my 30 seconds of research it looks like they are 1) pretty new, 2) basically VBA/macros for online


If I did an office script to accomplish this functionality, does that in any way translate to the workbook when I download it?


Such a simple thing. Seems weird to have to use an online-specific solution. As an aside, do you happen to know why CELL doesn't work online?




Does Office 365 Excel support VBA?


All versions of Windows desktop Excel from Excel 5 through Excel 2019 support VBA.

This includes the version of Excel installed by Office 365. ...

There is no version of Excel Online, iOS Excel or Android Excel that supports VBA.

Nor does any version of Excel that runs on Windows RT support VBA.


In my humble opinion, it would be good to always have the possibility of VBA in Excel.

All new options such as editing PDF and cloud options, in all future versions, will be require VBA.

Unless someone has already adjusted to Java script ... which I don't hope.


What I don't know is, if you maybe can open from the Developer tab in Visual Basic editor, I don't have Office 365 yet. You can try it, maybe…maybe it will work.

The sequence is in Excel 2016

     Click File

     Click Options

     Click Customize Ribbon

     Under the list of Main Tabs, select Developer

     Click OK

The Developer tab will now appear on the Ribbon and from it you can open the Visual Basic Editor.

 If opening the Developer tab and clicking a button is a little too much work, you can also open the editor with the keyboard shortcut Alt+F11, which works whether the Developer tab is enabled or not.

As I told you before, with the logic of Excel 2016.



I know I don't know anything (Socrates)



You are right, Office Script is relatively new functionality available only for targeted tenants, that means not for everyone so far. And yes, basically they have the same role as VBA/macro for desktop versions, but that's totally different technology. Since the engines which runs online and desktop versions are different.


Back to question, Excel Online has limited functionality compare to desktop version which, however, is expanded quite fast. To my knowledge there is no built-in function which allows to return file/sheet name. 

yeah, VBA is supported in O365 - this question is specific to Excel documents being intereacted with through a web browser (Excel online) though.

The CELL function which works on desktop does not work with online (weirdly), and same is true of VBA.

It's a pretty small detail (CELL formula not working online), not a critical functionality, just annoying to me, because I literally use the same header on every document as a matter of best practice.


- you may always check if function available for online version or not here Excel functions (alphabetical) In particular,  what it says for CELL


- you may vote for the idea to add CELL() for the online version here CELL function added to online . In theory more votes more chances it'll be added.  

- Perhaps one day functionality of desktop and online versions will be synced, at least that's how I understand Microsoft intention. But with that most probably not VBA will go online but Office Script will go on desktop. That's a long way.