View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
CaptainQuattro
 
Posts: n/a
Default Entering a filename as a variable into cell similar as for footer


Doug Wrote:
Would like to have a cell value the the name of the excell file I am
creating.
Similar to inserting the file name into the header or footer.


The following formula will return the full path, filename and current
sheet name:

=CELL("filename",A1)

Where it gets interesting is if you want to isolate the file name only.
For example, =CELL("filename",A1) may return

D:\Jupiter\MyDocuments\[doobie.xls]Sheet1

If all you want is

doobie.xls

you need:

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

The portion of the formula in red returns the position of the first
character of the actual filename.

The portion of the formula in blue returns the length of the actual
filename.
If all you want is -doobie.xls- you need the following:


--
CaptainQuattro
------------------------------------------------------------------------
CaptainQuattro's Profile: http://www.excelforum.com/member.php...o&userid=32763
View this thread: http://www.excelforum.com/showthread...hreadid=542743