cell content based on file name

kwagner1

Active Member
Joined
Jun 10, 2003
Messages
445
Greetings,
i want to have a cell populate with the first 10 bytes of my file name.
Ex. - filename= "2004-02-24_myfilename.xls"
- desired cell contents = 2004-02-24

any easy way of doing this??
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You can use the cell command.
Say the full path is c:\2004-02-24_myfilename.xls

Use:
=mid(cell("filename"),4,10)

If the path changes, you will need to change this to a search or find formula, rather than a mid formula. Post more detail in this case.
 
Upvote 0
Or, to allow for any path, search for the [ in the filnename, and return the next 10 characters

=MID(CELL("filename"),FIND("[",CELL("filename"))+1,10)

Richard
 
Upvote 0
Thanks! i took Richards method.... seems to have worked.

- one last question ..... is there a way to now format the cell so it shows a different date format? e.g. Feb 24, 2004

or, do i need to somehow reference the result from another cell ?
 
Upvote 0
Try:

=text(MID(CELL("filename"),FIND("[",CELL("filename"))+1,10) "mmm dd, yyyy")
 
Upvote 0
Or you could do:

=DATEVALUE(MID(CELL("filename"),FIND("[",CELL("filename"))+1,10))

and set the cell's number format.
 
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,938
Members
448,534
Latest member
benefuexx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top