Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Adding a File Path and Filename.

Adding a File Path and Filename

by Allen Wyatt
(last updated February 7, 2018)


Margo wants to insert a file path and filename in an Excel worksheet. She wants to be able to insert the information in either a cell or into the header/footer. This is rather easy to do in Excel.

To insert the file path and filename into a cell, you use the CELL worksheet function in the following manner:


This formula returns the entire path, filename, and tab name of the current worksheet, like this:

E:\My Data\Excel\[Budget.xls]Sheet1

If you want to strip out the brackets and the sheet name, you can use the following variation on the formula:


The LEFT function gets rid of everything from the right bracket to the end of the string, while the SUBSTITUTE function gets rid of the left bracket.

Putting a path and filename into a header or footer is easy:

  1. Select the worksheet whose header or footer you want to change.
  2. Choose the Page Setup option from the File menu. Excel displays the Page Setup dialog box.
  3. Click on either the Custom Header or Custom Footer buttons, as desired. Word displays either the Header or Footer dialog box. (See Figure 1.)
  4. Figure 1. The Header dialog box.

  5. Position the insertion point in the Left Section, Center Section, or Right Section boxes, as desired.
  6. Click on the File button. (It looks like a file folder with a piece of paper sticking out.) Excel inserts the following code at the insertion point:
  7.      &[Path]&[File]
  8. Click on OK two times to close both dialog boxes.

When you print the worksheet, Excel replaces the codes in step 5 with the path name and the file name of the workbook, respectively.

If you are using Excel 97 or Excel 2000, then the above steps won't work. Instead, you need to use a macro to insert the path and filename:

Sub DoFullPath()
    ActiveSheet.PageSetup.CenterFooter = _
End Sub

This macro will also work in later versions of Excel. To specify a different place for the path and filename, simply change CenterFooter to another location (such as LeftFooter, RightFooter, LeftHeader, CenterHeader, or RightHeader). If you decide to use the macro approach, you will need to remember to run it every time that you change either the workbook's filename (you use Save As), or you change the place where the workbook is stored on your disk.


If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2875) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Adding a File Path and Filename.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Nudging a Graphic

If you need to move a graphic just a little bit in one direction or another, you can do so by using the techniques in ...

Discover More

Getting a Double-Spaced Printout

When working with printed documents, many people prefer to see the document double-spaced. If you have a single-spaced ...

Discover More

Adding Information after the Endnotes

Endnotes appear at the end of the document, right? Not always, as Word provides a way that you can actually add as much ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Seeing Full File Names in the Files Menu

Wouldn't it be great if you could look at the files in the MRU list and see the full path and file names? Excel condenses ...

Discover More

Getting Rid of "Copy of"

When you save a read-only workbook file under a new name, Excel automatically adds "copy of" to the beginning of that ...

Discover More

Importing Many Files Into Excel

Importing a single file is easy. Importing a whole slew of files can be much more of a challenge.

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 4 + 0?

2018-08-30 16:17:29

Ian Fitzhenry

Brilliant tip - easy when you know how

2018-07-10 21:41:01


I get very frustrated when "EXPERTS" instructions DO NOT WORK!
These instructions DO NOT APPLY to Office 365.
I wasted my time attempting to follow these instructions which leave LOTS to be desired.
Clicking on the link for higher versions takes me right back here.

2017-04-07 17:31:23

Guest User

BEST TIP! Literally just copied and pasted the formula and it worked flawlessly. So easy to follow! THANK YOU!

2016-07-07 06:31:35



2016-03-10 07:36:21

Noel Hempseed

I am not that excel savvy. I do not follow the example.Would it be possible to illustrate simply what areas of the worksheet I would go to to put the EMy DataExcel etc in the worksheet so that it would print out at the foot of the worksheet.

Noel Hempseed

March 10, 2016

2016-01-26 08:15:26


Great site! Kudos!!! So much better than Microsoft's obtuse Help :)
Thanks for a nice contribution to all of us out here!

2014-12-02 15:09:10


I would like to customize a header for a worksheet so that I do not have to manually change it every quarter when I print a (quarterly financial)report. The four options would be First Quarter, Second Quarter, Third Quarter, and Fourth Quarter. I already have dates in the worksheet and ideally would like it to read off of that. E.g., if the date is 9.30.xx, then it would automatically print with Third Quarter. If it was 12.31.xx, then it automatically print Fourth Quarter. Can this be done?

2014-10-24 07:56:52

Michael (Micky) Avidan

("úøùéí 1") should read: ("Chart 1").
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)

2014-10-24 07:25:07

Michael (Micky) Avidan

Insert a TextBox under the X Axis and run the following Macro:
Sub User_Name_Chart_Title()
ActiveSheet.ChartObjects("úøùéí 1").Activate
ActiveChart.Shapes.Range(Array("TextBox 1")).Select
With Selection.ShapeRange.TextFrame2.TextRange
.Characters.Text = "User Name: " & Environ("username")
.ParagraphFormat.Alignment = msoAlignCenter
End With
End Sub
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)

2014-10-23 05:37:19


Thanks Micky,

I will work on this approach. I don't want to make the user's name equal to the chart title; I just want it to appear buried down in the footer area, near the date, time, path and file name.

Is there an equivalent term to "ActiveChart.ChartTitle.Text" but just for the Footer area? ActiveChart.Footer.Center.Text?

2014-10-22 09:13:36

Michael (Micky) Avidan

Try to run the following Macro:
Sub User_Name_Chart_Title()
For Each CH In ActiveSheet.ChartObjects
ActiveChart.HasTitle = True
ActiveChart.ChartTitle.Text = "User Name: " & Environ("username")
End Sub
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)

2014-10-21 23:45:37


How can I add a user's name into the footer of an Excel chart? In other words, is there an "&[User]" element code, similar to &[Path], &[File], &[Date], etc.? This would be particularly useful in identifying charts printed from shared network files.

2014-08-15 07:22:07

Michael (Micky) Avidan

What is the EXACT function you are using ?
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)

2014-08-14 08:58:34


when i am using filename function in excel 1 (this is the filename) , and then i open excel 2, the cell in excel 1 changes from "excel 1" to "excel 2".

Please advise, how to prevent this.

2013-11-10 21:50:04


In Excel 2003, I have added =CELL("filename")in cell A1 to all sheets of a workbook. The sheet name provided by this function does not change when I make a different sheet the active one. After making the different sheet the active one, I can change the sheet name by hitting F2. Is there a way to cause the sheet name to change when I activate a different sheet within the book?

2013-11-02 12:21:31


how do i keep a filepath in the footer of an excel worksheet even when email the wsheet to someone.
When emailing it changes the path to the temporary file linked to emails

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.