File Name in Spreadsheet :: MrExcel Message Board



 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

File Name in Spreadsheet
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

Mechanic
Board Regular


Joined: 27 Mar 2002
Posts: 49

Flag: Blank

Status: Offline

 Reply with quote  

File Name in Spreadsheet

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

Post Fri Sep 19, 2003 9:35 pm 
 View user's profile Send private message

Mark W.
MrExcel MVP


Joined: 11 Feb 2002
Posts: 7146
Location: Austin, Texas USA
Flag: Usa

Status: Offline

 Reply with quote  

Re: File Name in Spreadsheet

See the Excel Help topic for the CELL worksheet function.

Post Fri Sep 19, 2003 9:45 pm 
 View user's profile Send private message

pennysaver
Board Master


Joined: 15 May 2003
Posts: 2189
Location: San Diego, California
Flag: Usa

Status: Offline

 Reply with quote  

Re: File Name in Spreadsheet

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

Post Fri Sep 19, 2003 9:56 pm 
 View user's profile Send private message Visit poster's website MSN Messenger

Yogi Anand
MrExcel MVP


Joined: 13 Mar 2002
Posts: 5749
Location: Michigan USA

Status: Offline

 Reply with quote  

Re: File Name in Spreadsheet

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)
_________________
Regards!
Yogi Anand

Post Fri Sep 19, 2003 10:56 pm 
 View user's profile Send private message

Yogi Anand
MrExcel MVP


Joined: 13 Mar 2002
Posts: 5749
Location: Michigan USA

Status: Offline

 Reply with quote  

Re: File Name in Spreadsheet

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)
_________________
Regards!
Yogi Anand

Post Fri Sep 19, 2003 10:59 pm 
 View user's profile Send private message

pennysaver
Board Master


Joined: 15 May 2003
Posts: 2189
Location: San Diego, California
Flag: Usa

Status: Offline

 Reply with quote  

Re: File Name in Spreadsheet

Thanks Yogi,

You always catch the schnznit that I miss!

Smitty

Post Sat Sep 20, 2003 5:05 am 
 View user's profile Send private message Visit poster's website MSN Messenger

Travis
Board Master


Joined: 27 Feb 2002
Posts: 439
Location: Phoenix, Arizona
Flag: Usa

Status: Offline

 Reply with quote  

Re: File Name in Spreadsheet

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


Post Sat Sep 20, 2003 5:55 am 
 View user's profile Send private message Send e-mail
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.