ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   EASY QUESTION: Formula to add filename to cell (https://www.excelbanter.com/excel-programming/381540-re-easy-question-formula-add-filename-cell.html)

Chip Pearson

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?





All times are GMT +1. The time now is 06:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com