File name insertion in cell

B

balterson

I have the =cell("filename",a1) formula, but what if you only what just the
file name and not the whole path??? This is driving me crazy, that I can't
figure it out.

Thank you
Bonnie
 
G

Gord Dibben

File path, file and worksheet name:
=CELL("filename",A1)

File path only:
=LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1),1)-1)

File name only:
=MID(CELL("filename",A1),FIND("[",CELL("filename",A1),1)+1,FIND("]",CELL("filename",A1),1)-FIND("[",CELL("filename",A1),1)-1)

The sheet name:
=MID(CELL("Filename",A1),FIND("]",CELL("Filename",A1))+1,255)

More on this can found at Bob Phillips' site.

http://www.xldynamic.com/source/xld.xlFAQ0002.html


Gord Dibben MS Excel MVP
 
G

Gary''s Student

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

Dave Peterson

And check your other post, too.
I have the =cell("filename",a1) formula, but what if you only what just the
file name and not the whole path??? This is driving me crazy, that I can't
figure it out.

Thank you
Bonnie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top