View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default EASY QUESTION: Formula to add filename to cell

"Martin" wrote in message
=CELL("filename")


If only it were really that simple. You'll get into problems with that
formula if the workbook containing that formula is not the active workbook
when Excel decides to do a full recalculation. Moreover, your formula
includes the square brackets around the file name and includes the sheet
name. Instead, use the following formula:

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


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Martin" wrote in message
...
=CELL("filename")

"b" wrote:

Is there a formula I can use that will place the file name in a cell?