Extracting Month and Year from File Name

bearcub

Well-known Member
Joined
May 18, 2005
Messages
702
Office Version
  1. 365
  2. 2013
  3. 2010
  4. 2007
Platform
  1. Windows
I have the following formula in A1 to show the current file Name

Code:
MID(CELL("filename"),SEARCH("[",CELL("filename"))+1, SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1)

Result in A1:
Aug 2018 New Employee-Term File.xlsx

[code//] <- What is the correct syntax so it shows up as code (I forgot how to do it)

I would like to extract the month and year portion of the file name.

I did try using the left combined with the Search and Find functions but was unsuccessful.

Thank you for your help,

Michael
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
If the result in A1 always starts with mmm yyyy, try:
Code:
=Left(A1,8)
to return the string mmm yyyy.
 
Upvote 0
Thank you Joe, but this isn't quite what I was looking for (my bad in the explanation).

I would like to use the mid formula in cell A1 but I would like only to show the month and day instead of the full path. I think your formula is in a another cell, not A1. I would like to learn how to have the formula in one cell (finding the file name and then extracting only part of the name).

thank you for your help.

BTW, how do I get the code to show up properly

The first part is
Code:
 but how to I close it?

Michael
 
Upvote 0
If you want it all in one formula, and provided the info you want is always at the start, try this in A1:
Code:
=LEFT(MID(CELL("filename"),SEARCH("[",CELL("filename"))+1, SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-1),8)
The close code tag is the same as the open except add a forward slash (" / ")before the c in code.
 
Upvote 0
Thank you Joe, this will work and thank you for the code tidbit.
 
Upvote 0
What about just this?

=MID(CELL("filename"),FIND("[",CELL("filename"))+1,8)
 
Upvote 0
Thank you, is there anyway to automate the 8 os that if the month and date have 9 characters I wouldn't have to change it to 9:

=MID(CELL("filename"),FIND("[",CELL("filename"))+1,8)
=MID(CELL("filename"),FIND("[",CELL("filename"))+1,9)
 
Upvote 0
Thank you, is there anyway to automate the 8 os that if the month and date have 9 characters I wouldn't have to change it to 9:

=MID(CELL("filename"),FIND("[",CELL("filename"))+1,8)
=MID(CELL("filename"),FIND("[",CELL("filename"))+1,9)
This will work for 8 (mmm yyyy) or 9 (mmmm yyyy), provided the 9th character is a space when the date is mmm yyyy:
Code:
=TRIM(MID(CELL("filename"),FIND("[",CELL("filename"))+1,9))
 
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,726
Members
449,093
Latest member
Mnur

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