ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert file name into sheet (https://www.excelbanter.com/excel-programming/355532-insert-file-name-into-sheet.html)

Darin Kramer

Insert file name into sheet
 


Hi There,

I want to have the file name appear in cell a5, on a sheet (say called
"test"). It needs to be able to update when users changes file name..

Any ideas....

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***

Ardus Petus

Insert file name into sheet
 
=CELL("flename")

HTH
--
AP

"Darin Kramer" a écrit dans le message de
...


Hi There,

I want to have the file name appear in cell a5, on a sheet (say called
"test"). It needs to be able to update when users changes file name..

Any ideas....

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***




Darin Kramer

Insert file name into sheet
 
Thanks - but that inserts path as well as filename - is it possible just
to get file name?

Regards

D

*** Sent via Developersdex http://www.developersdex.com ***

Ardus Petus

Insert file name into sheet
 
Assuming your =CELL formula is in A1

Enter the following in B1:

=MID(A1,SEARCH("[",A1)+1,SEARCH("]",A1)-SEARCH("[",A1)-1)

HTH
--
AP


"Darin Kramer" a écrit dans le message de
...
Thanks - but that inserts path as well as filename - is it possible just
to get file name?

Regards

D

*** Sent via Developersdex http://www.developersdex.com ***




Chip Pearson

Insert file name into sheet
 
=CELL("filename")

You need to include a cell reference in the call to CELL. E.g.,

=CELL("filename",A1)

Otherwise, the function will return the name of the workbook that
is active when the formula is calculated, which may not be the
same workbook that contains the formula. The cell reference (it
can be any cell -- it doesn't matter) ensures that the correct
workbook name is returned.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ardus Petus" wrote in message
...
=CELL("flename")

HTH
--
AP

"Darin Kramer" a écrit dans le
message de
...


Hi There,

I want to have the file name appear in cell a5, on a sheet
(say called
"test"). It needs to be able to update when users changes file
name..

Any ideas....

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***






GS

Insert file name into sheet
 
In agreement with Chip's recommendation, and to facilitate using only one
cell, you could enter Ardus's formula like this:

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

Regards,
GS


All times are GMT +1. The time now is 10:44 PM.

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