Site icon Professor Excel

File Name, Sheet Name: Easily Insert File Data in Excel!

There are many cases, in which you want to show the sheet name or file name in an Excel cell. Don’t worry, you don’t have to use VBA and create a macro. Excel provides a (rough) formula for returning all the information you need. The bad news: In most cases it takes some complex modifications. The good news: Usually you can just copy and paste the formula you need.

Introduction: Get all the names you need

Fortunately, you don’t have to use VBA. There are formulas for each variation of the sheet name, file name and path. The main part of the formula is the =CELL() formula.

The CELL formula looks something like this: =CELL(“filename”,A1). That means that the CELL formula we have to use has two parts:

  1. The first part just says “filename”. It is important to add the quotation marks.
  2. The second part is optional and can link to any cell or workbook. If you leave it blank the current cell and workbook will be used.

The basic version of the CELL formula (=CELL(“filename”,A1) ) returns the full path, file name and sheet name. You can use this formula and cut it into the parts you need. Therefore you use string formulas like LEFT, LEN and so on. We won’t go into detail now as those formulas are highly specific and complex but rather provide the formulas for you to copy.

Note: We’ve published an article about three methods of how to get the sheet name. Maybe this one is interesting for you as well.

The formulas for sheet name, file name, path etc.

The formulas for inserting file names, sheet names or the path (with and without the extension) are very different. This table gives you an overview. If you want to copy the formulas, you can find them underneath again.

Overview: All the formulas for getting a file name, sheet name or path in Excel

Copy these formulas for the current cell or sheet:

Copy these formulas for any linked cell or sheet:

If you want to get the file name, sheet name or path from another cell or workbook, you can use one of the following formulas. Instead of “A1” you insert your cell reference.

Please note:

Download an Excel file with all the formulas

Download the formulas within this Excel file so that it adapts to your language and regional settings automatically

In order to avoid any problems with language and regional settings, you can download all the above formulas with an Excel file.

Just open it and copy the complete cell to your desired location. The download starts instantly (no sign-up or any other annoyances…).

Anything missing? Suggestions for improvements? Please let us know and leave a comment.

Exit mobile version