filename – This is a system defined input for the CELL function.
What It Does
This formula will return the sheet name of the current sheet.
How It Works
CELL(“filename”) will return the full file path of the current workbook (let’s call this the FilePath) which includes the folder path, workbook name and the current sheet name. In our example FilePath is C:\Users\John\[How to Get the Current Sheet Name.xlsx]My Sheet.
FIND(“]”,FilePath) will return the location of the “]” character before the sheet name (let’s call this the Location). In our example FIND(“]”,FilePath) returns the value 132 since “]” is the 132nd character in the FilePath text string.
LEN(FilePath) will return the total character length of the FilePath text string (let’s call this the TotalLength). In our example LEN(FilePath) returns the value 140 since there are 140 characters in the text string.
We can now get the length of the sheet name by subtracting TotalLength-Location. In our example the sheet name length is 140-132=8 characters.
RIGHT(FilePath,TotalLength-Location) will then return the right most 8 characters of the FilePath, which gives us the sheet name. In our example this is My Sheet.