Excel Formula for File Path: Get the Workbook Location

Formulas & functions · Updated November 18, 2026

In Excel for Microsoft 365 on Windows, use =CELL("filename",A1) to return the saved workbook’s path, file name, and active sheet name in one text string. The workbook must be saved first; to return just its folder, extract the text before the opening square bracket in that result.

The basic Excel file path formula

The CELL function can return information about a cell or its worksheet. Its "filename" information type returns a text value containing the workbook’s location, workbook name, and the name of the sheet containing the referenced cell. For a workbook saved in C:\Reports, the result might look like C:\Reports\[Quarterly.xlsx]Summary. The exact path and separator style depend on where the workbook is saved and which operating system is in use.

With the formula entered in B1 and A1 referring to a cell on the current sheet, use:

=CELL("filename",A1)

This is often described as the Excel formula for a file path, but it is important to understand what the result includes: it is not just a folder path. The folder comes first, followed by the workbook name in square brackets and then the worksheet name. The formula reports the workbook containing the formula, not a separate file named in another cell.

How CELL returns the location

The formula reads workbook information rather than searching your computer’s folders. In the example C:\Reports\[Quarterly.xlsx]Summary, C:\Reports\ is the folder, Quarterly.xlsx is the workbook name, and Summary is the worksheet. A reference such as A1 tells Excel which sheet’s name to include; A1 does not need to contain data.

A saved workbook is essential. Before the first save, Excel does not have a regular saved file location to return, so the result can be blank. If the formula is used inside another calculation, that empty result can cause an extraction formula to return an error. Save the workbook to the intended location, then check the result again. If it appears outdated after moving or renaming the file, recalculate the workbook with F9 on Windows.

Return only the folder, file name, or sheet

Because the full result has a consistent bracketed structure, you can extract individual parts with text functions. The following examples use the familiar square-bracket format returned for a saved desktop workbook. Each formula includes an error message for an unsaved workbook.

With A1 referring to any cell on the current sheet and the formula placed in B1, return the folder path before the workbook name:

=IFERROR(LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1))-1),"Save workbook first")

For C:\Reports\[Quarterly.xlsx]Summary, the result is C:\Reports\. The trailing backslash is part of the folder path. Keeping it can be useful when you combine the result with another file name, but check whether the next piece of text already starts with a separator to avoid creating a doubled one.

With A1 referring to a cell on the current sheet and the formula in B1, return only the workbook file name:

=IFERROR(MID(CELL("filename",A1),FIND("[",CELL("filename",A1))+1,FIND("]",CELL("filename",A1))-FIND("[",CELL("filename",A1))-1),"Save workbook first")

For the same example, this returns Quarterly.xlsx, including the extension. It does not return the folder or sheet name.

With A1 referring to a cell on the current sheet and the formula in B1, return the sheet name after the closing bracket:

=IFERROR(MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,LEN(CELL("filename",A1))),"Save workbook first")

This returns Summary. The formula extracts the text after the workbook name, so it can also return sheet names containing spaces. If you use these results to build a file path, remember that a sheet name is not part of a Windows folder path.

A shorter option in newer Excel versions

Microsoft 365 and Excel 2024 include TEXTBEFORE and TEXTAFTER, which can make extraction easier to read. These functions are not available in every older Excel release, so use the earlier LEFT, MID, and FIND examples if a workbook needs to work with older versions.

With A1 referring to a cell on the current sheet and the formula placed in B1, return the folder portion:

=IFERROR(TEXTBEFORE(CELL("filename",A1),"["),"Save workbook first")

With A1 referring to a cell on the current sheet and the formula placed in C1, return the workbook name between the brackets:

=IFERROR(TEXTBEFORE(TEXTAFTER(CELL("filename",A1),"["),"]"),"Save workbook first")

Both versions still depend on a saved workbook. Their advantage is readability, not access to a different kind of location data.

Enter and use the formula

To add a path formula to a workbook, select a cell where the result should appear, type or paste the formula, and press Enter. Use a cell reference on the sheet whose name you want included. If you copy the formula to another sheet, check that the reference still points to the intended sheet; a relative reference can change as it is copied.

A practical setup might place the full result in B1, the folder in B2, and the file name in B3. Put a label next to each result so other users know whether a value is a folder, workbook, or sheet name. The formula returns text; it does not create a clickable link, move the workbook, or automatically add a file name to a report.

On Windows, F9 recalculates formulas. On a Mac, the corresponding shortcut is typically Fn+F9, though keyboard settings and the model can affect function-key behavior. You can also recalculate from Excel’s Formulas tab. Excel for the web runs in a browser and may not expose a local Windows-style file path; a cloud workbook’s location is not necessarily the same as a path on your computer.

What changes on Mac, in the web, and with cloud files

On a Mac, CELL("filename",A1) is still the relevant worksheet formula, but the returned location can use Mac-style path conventions rather than a drive-letter path such as C:\Reports\. Do not build a formula that assumes every user’s path begins with a particular drive letter or uses backslashes. If a workbook moves between Windows and Mac, test any downstream text extraction or path-building logic on both platforms.

Excel for the web has a different relationship to files: it works with files opened through a browser, often in OneDrive or SharePoint, and cannot reveal a local folder path in the same way as desktop Excel. Depending on how and where the workbook is saved, the formula may not provide the location a user expects. If you need a shareable location for a cloud workbook, use the service’s sharing or copy-link options rather than treating the formula result as a web URL.

For a workbook stored in a locally synchronized OneDrive or SharePoint folder and opened in desktop Excel, the result may reflect a local synchronized location. That is not automatically a link that another person can open. A colleague may have a different local folder, permissions, or sync setup.

Limits and common problems

The formula is useful for identifying the current workbook, but it has practical limits. Keep these points in mind when adding it to a template or report:

  • The workbook must be saved. An unsaved workbook has no established saved path, so the full result can be blank and extraction formulas may show an error.
  • It identifies the current workbook only. A path typed in a cell, or the name of another open workbook, does not make CELL("filename",A1) return that other file’s location.
  • A path is not a hyperlink. The returned text does not guarantee that clicking it will open the workbook or that another person can access it.
  • Folder structure can differ. Windows, Mac, synchronized cloud folders, and browser-based workbooks can represent locations differently.
  • Moving or renaming a workbook can leave a stale-looking result until recalculation. Recalculate and confirm the workbook has been saved at its new location.

If the formula returns an unexpected blank or error, first save the file, then confirm the formula refers to a cell on the intended sheet. Also check whether the workbook is open in desktop Excel or Excel for the web. When a formula extracts text using brackets, it relies on the expected bracket structure being present; if the original CELL result is empty or different, the extraction cannot work as intended.

Formula result versus a clickable file link

A file path and a hyperlink serve different purposes. A path is text describing a location. A hyperlink is an action a user can follow to open a file or location, subject to access and application settings. CELL("filename",A1) reports where the current workbook is saved; it does not generate a share link or link to a file named in another cell.

If your goal is to help someone open a document, use Excel’s Insert Link command or the HYPERLINK function with a known, valid destination. Do not assume that the current workbook’s path can be adapted into a working link for everyone: a local path may exist only on your computer, and a cloud link may require permissions. If your goal is simply to display the current workbook’s location in a worksheet, the CELL formula is the direct option.

Privacy and sharing considerations

A path can reveal more than a file name. It may include a person’s Windows user-folder name, department names, project labels, or internal folder structure. Before distributing a workbook, consider whether showing that information is appropriate for its audience. A formula result remains visible worksheet content, even if the formula cell is tucked into a hidden column or a supporting sheet.

Also distinguish between hiding a value and removing it. If the path should not be shared, remove the formula and its displayed result from the distributed copy, or replace it with a neutral label. Do not rely on hiding a worksheet as a privacy safeguard, because recipients may be able to unhide it or inspect workbook contents.

Frequently Asked Questions

Does CELL(“filename”,A1) return the folder only?
No. It normally returns the folder, workbook name in square brackets, and sheet name. Use a text-extraction formula to return just the folder, and remember that the workbook must be saved.

Why is my Excel file path formula blank?
The most common reason is that the workbook has not been saved yet. Save it, then recalculate if needed. In Excel for the web, a browser-based location may not appear as a local computer path.

Can the formula find the path of another workbook?
Not by itself. The CELL formula reports information about the workbook containing the referenced cell. It does not look up the location of an arbitrary file from its name.

Does the result include the worksheet name?
Yes. The result normally appends the referenced cell’s sheet name after the workbook name. You can extract the sheet text after the closing square bracket if you need it separately.

Will the path formula work in Excel for the web?
Do not count on it to return a local Windows-style path. Excel for the web works with browser-accessed files, so use OneDrive or SharePoint’s sharing tools when you need a cloud link that other people can open.

Does the formula create a link to the workbook?
No. It returns text describing the workbook’s location. To make a clickable destination, use a valid hyperlink separately and confirm that the intended users have access to it.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.