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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

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.
 

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
 

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 ?
 

tactps

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

ADVERTISEMENT

Try:

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

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.
 
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,491
Messages
5,764,675
Members
425,229
Latest member
Rashid mahmood

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