File Name in Spreadsheet

Mechanic

Board Regular
Joined
Mar 26, 2002
Messages
60
Is there a function that places the spreadsheet name in a cell within the same spreadsheet, so that when I rename the spreadsheet it will update that cell and I won't have to type the new name in each time ? Excel 97 is what I have.

Mechanic
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
For File Name with Path & Sheet Name:

=CELL("FILENAME")

For full File Name with Path:

=SUBSTITUTE(LEFT(CELL("filename",A1),FIND("]",CELL("filename",A1))-1),"[","")

For File Name only;

=MID(CELL("FILENAME",A1),FIND("[",CELL("FILENAME",A1))+1,FIND("]",CELL("FILENAME",A1))-FIND("[",CELL("FILENAME",A1))-5)

Hope that helps,

Smitty
 
Upvote 0
Hi smitty:

=cell("filename")
in a cell will display the name of the active file

to ensure that the cell A1 displays the name of the file to which the cell and its worksheet belong to, I will use

=cell("filename",A1)
to anchor the name of the corresponding file in cell A1.

(I did see that further down in your post you did anchor the filename in cell A1)
 
Upvote 0
And for the name of the workbook only,

the following worked for me ...

=MID(A1,FIND("[",A1)+1,FIND("]",A1)-(FIND("[",A1)+1))

where A1 contains =cell("filename",A1)
 
Upvote 0
If you dont want it in a cell, this will print it in the footer whenever you print the file...

Code:
Private Sub Workbook_BeforePrint (Cancel As Boolean)
ActiveSheet.PageSetup.LeftFooter = "&8" & UCase (ActiveWorkbook.FullName)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top