Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 160
Default How can I show the current file name in a cell.

How do you get excel to return the name of the current workbook into a
certain cell.
I can get the directory name by typing =Info("directory"), but I cannot get
the filename.
Is there a function that will return the current file name.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default How can I show the current file name in a cell.

Try one of these** :

This will return the full path including the sheet name:

=CELL("filename",A1)

Result will be something like: C:\TV\[Sheet name.xls]Sheet1

This will return just the file name including the file extension:

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

Result will be something like: Sheet name.xls

** the file must already exist. In other words, it must have been saved at
least once and given a file name.


--
Biff
Microsoft Excel MVP


"Patrick" wrote in message
...
How do you get excel to return the name of the current workbook into a
certain cell.
I can get the directory name by typing =Info("directory"), but I cannot
get
the filename.
Is there a function that will return the current file name.

Thanks



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 434
Default How can I show the current file name in a cell.

hi, Patrick !

How do you get excel to return the name of the current workbook into a certain cell.
I can get the directory name by typing =Info("directory"), but I cannot get the filename.
Is there a function that will return the current file name.


for the current (and saved) workbook...

path: =left(cell("filename"),find("[",cell("filename"))-2)
name: =mid(cell("filename"),find("[",cell("filename"))+1,find("]",cell("filename"))-find("[",cell("filename"))-5)
sheet: =mid(cell("filename"),search("]",cell("filename"))+1,now())

when the workbook has only one sheet names same as the workbook...
sheet: =mid(cell("filename"),if(iserror(find("]",cell("filename"))),lookup(2,1/(mid(cell("filename"),row($1:$255),1)="\"),row($1: $255))+1,find("]",cell("filename"))+1),31)

hth,
hector.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting cell to show current Quarter S trainer Excel Worksheet Functions 2 May 6th 08 09:31 PM
How do i assign cell A1 to show the current cursor cell in Excel? OB Excel Discussion (Misc queries) 2 October 11th 06 04:02 PM
Show current date in cell Alex01 Excel Discussion (Misc queries) 4 February 24th 06 06:45 PM
I want a cell to show the current filename automatically. Troy Excel Discussion (Misc queries) 4 January 31st 06 02:32 PM
how do i insert the current time into a cell, and show different . Dave Excel Discussion (Misc queries) 1 March 22nd 05 06:57 PM


All times are GMT +1. The time now is 05:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"