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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,460
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

RichardS

Well-known Member
Joined
Feb 16, 2002
Messages
761
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

kwagner1

Active Member
Joined
Jun 10, 2003
Messages
445
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

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,460
Try:

=text(MID(CELL("filename"),FIND("[",CELL("filename"))+1,10) "mmm dd, yyyy")
 
Upvote 0

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
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,186,808
Messages
5,959,926
Members
438,454
Latest member
leopedrini

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
Top