Excel Guides

Getting the Name of the Worksheet Into a Cell in Excel

There are a few different ways that you can get the name of the worksheet into a cell in Excel. One way is to use the CELL function. The CELL function returns information about the formatting, location, or contents of a cell. You can use it to get the worksheet name by using the following formula:

=CELL("filename")

Another way to get the name of the worksheet into a cell is to use a macro. To do this, you will first need to create a new module in your workbook. To do this, go to Insert > Module. Then, paste the following code into the module:

Sub GetSheetName()
ActiveSheet.Range("A1").Value = ActiveSheet.Name
End Sub

Now, whenever you want to get the name of the current worksheet into cell A1, simply run the macro by going to View > Macros, selecting GetSheetName, and clicking Run. Finally, you can also use a custom function to get the name of the worksheet into a cell.

Function SheetName() As String 
 SheetName = ActiveSheet.Name 
End Function

To use this function, simply enter =SheetName() into any cell.

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.