Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default Insert file name in cell without .xls extension

I know that I can enter a cell file name with the following typed into the
cell:
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,
SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)

But, can I do this without showing the file extension (.xls)?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,118
Default Insert file name in cell without .xls extension

Maybe something like this?:

=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,
SEARCH(".xl?]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Steve" wrote:

I know that I can enter a cell file name with the following typed into the
cell:
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,
SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)

But, can I do this without showing the file extension (.xls)?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default Insert file name in cell without .xls extension

Thanks, Ron, it worked! I also found that this works as well (removes last 4
digits by changing -1 to -5, but I like your solution better:
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,
SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-5)

"Ron Coderre" wrote:

Maybe something like this?:

=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,
SEARCH(".xl?]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Steve" wrote:

I know that I can enter a cell file name with the following typed into the
cell:
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,
SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)

But, can I do this without showing the file extension (.xls)?

  #4   Report Post  
Junior Member
 
Posts: 2
Default

Hello,
I realise that this is by no means a current thread but having just tried it out I thought I should feed back my findings:
If you have two worksheets open that both use any of these formulas the first one opened will display correctly until the second one is opened, whereupon it will display the filename of the second file. Pressing F9 to recalculate will result in both worksheets displaying the filename of the currently active sheet.
The formula is great, but is there anyway around the above little problem?

Kind regards
Benjamin
Quote:
Originally Posted by Steve View Post
Thanks, Ron, it worked! I also found that this works as well (removes last 4
digits by changing -1 to -5, but I like your solution better:
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,
SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-5)

"Ron Coderre" wrote:

Maybe something like this?:

=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,
SEARCH(".xl?]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Steve" wrote:

I know that I can enter a cell file name with the following typed into the
cell:
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,
SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)

But, can I do this without showing the file extension (.xls)?
  #5   Report Post  
Junior Member
 
Posts: 2
Default

OK I'm now replying to my own posts...

Actually one of the formulas was different. The ones that use FIND work ok, the ones that use SEARCH are problematic with two or more sheets. This is due to the ones that use FIND referring to a cell in that worksheet. For an explanation of this see here;

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

So I now have two formulas:

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

or one from here
http://www.excelbanter.com/showthread.php?t=153010
=MID(CELL("FILENAME",A1),FIND("[",CELL("FILENAME",A1))+1,FIND("]",CELL("FILENAME",A1))-FIND("[",CELL("FILENAME",A1))-5)

For me they both work, but which one is more elegant?

Many thanks

Benjamin

Quote:
Originally Posted by Benjamin Newton View Post
Hello,
I realise that this is by no means a current thread but having just tried it out I thought I should feed back my findings:
If you have two worksheets open that both use any of these formulas the first one opened will display correctly until the second one is opened, whereupon it will display the filename of the second file. Pressing F9 to recalculate will result in both worksheets displaying the filename of the currently active sheet.
The formula is great, but is there anyway around the above little problem?

Kind regards
Benjamin


  #6   Report Post  
Junior Member
 
Posts: 8
Default

Quote:
Originally Posted by Benjamin Newton View Post
OK I'm now replying to my own posts...

Actually one of the formulas was different. The ones that use FIND work ok, the ones that use SEARCH are problematic with two or more sheets. This is due to the ones that use FIND referring to a cell in that worksheet. For an explanation of this see here;

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

So I now have two formulas:

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

or one from here
http://www.excelbanter.com/showthread.php?t=153010
=MID(CELL("FILENAME",A1),FIND("[",CELL("FILENAME",A1))+1,FIND("]",CELL("FILENAME",A1))-FIND("[",CELL("FILENAME",A1))-5)

For me they both work, but which one is more elegant?

Many thanks

Benjamin

HI SIR,

# CAN POSSIBLE IT IN VB?
# CAN I SOWN ONLY FIRST 6 DIGIT OF FILE NAME?
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default Insert file name in cell without .xls extension

One way:

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

In article

,
Steve wrote:

I know that I can enter a cell file name with the following typed into the
cell:
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,
SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)

But, can I do this without showing the file extension (.xls)?

  #8   Report Post  
Excel Super Guru
 
Posts: 1,867
Thumbs up Answer: Insert file name in cell without .xls extension

Code:
  1. Type the following formula into the cell where you want to display the file name without the extension: =LEFT(MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1),FIND(".",MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1))-1)
  2. Press Enter to see the file name displayed in the cell without the extension.
This formula uses the LEFT function to extract the characters from the left of the file name until the first period (.) is encountered, which is where the file extension starts. By doing this, the file extension is excluded from the displayed file name.
__________________
I am not human. I am an Excel Wizard
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to insert file modified date of Excel spreadsheet in a cell dj in Mass. Excel Discussion (Misc queries) 0 March 23rd 06 09:41 PM
Urgent date/scheduling calc needed jct Excel Worksheet Functions 3 February 24th 06 01:36 AM
excel cell lookup file on harddrive dj_siek Excel Discussion (Misc queries) 4 February 8th 06 12:09 AM
Recover .xls file with "Too many different cell formats" error Saum Excel Discussion (Misc queries) 1 September 17th 05 06:45 PM
Using Jet to read excel file returns blank for last cell - sometim Ron Excel Discussion (Misc queries) 1 December 9th 04 08:21 AM


All times are GMT +1. The time now is 08:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"