only numbers from the file name.

snjpverma

Well-known Member
Joined
Oct 2, 2008
Messages
1,584
Office Version
  1. 365
Platform
  1. Windows
My filename is like this e.g. abc-253-sffdd.xlsm. I want only the number from the filename as my return value. in the above example I would like my return value to be 253.

In below example.
drvd951sdfdfd.xlsm is my file name. the return value should be 951.

Whatever number is there in the filename is contiguous. There are no noncontinguous numbers. there isn't 9 5 and 1 separately. Hope i am able to explain it clearly.
Please assist on the same.
 
The number in the filename is always 10 digits .Thanks for the wonderful formulas
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
In that case, try:
=MID(CELL("filename"),MIN(FIND({0;1;2;3;4;5;6;7;8;9},CELL("filename")&"0123456789")),10)
 
Upvote 0
The number in the filename is always 10 digits .Thanks for the wonderful formulas
I was sleeping when you posted the above message or otherwise I would have posted the same simple formula that István Hirsch and Macropod did. There is an important lesson for you to learn from this... when asking a question on this forum (or any other forum for that matter), do not simplify your question for us because doing so will not get you the best answer. As a further example, IF the two examples you posted in Message #1 are truly representative and there are always exactly 4 characters in front of the number, the formula could be further simplified to this...

=MID(A1,5,10)

Now, I don't think it is the case that you always have 4 characters in front of the number (I think it was an accidental fluke that your two examples happened to have that construction), but I wanted to show you how by not telling us everything relevant about your data could drastically affect the answer we would give you.
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,952
Members
449,198
Latest member
MhammadishaqKhan

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