Extract specific number from alphanumeric string

Gfletch63

New Member
Joined
Mar 2, 2018
Messages
6
Here is a sample string from a cell in my spreadsheet:

PTG X 4 / 60 MINS UNLD

I need to grab the 60 out of that string. The word MIN or MINS is always to the right of the number, and the number is always either 2 or 3 digits.

Sounds like it should be simple, but...not for me.

<tbody>
</tbody>
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Here is a sample string from a cell in my spreadsheet:

PTG X 4 / 60 MINS UNLD

I need to grab the 60 out of that string. The word MIN or MINS is always to the right of the number, and the number is always either 2 or 3 digits.

Sounds like it should be simple, but...not for me.

<tbody>
</tbody>
Is that the exact structure of all your data... text, an X, a space, a number, a space, a slash, a space, the number you want, a space, the word MIN or MINS followed by more text? If not, show us a representative sampling of what your cells can contain and tell us the desired value for each.
 
Last edited:
Upvote 0
Is that the exact structure of all your data... text, an X, a space, a number, a space, a slash, a space, the number you want, a space, the word MIN or MINS followed by more text? If not, show us a representative sampling of what your cells can contain and tell us the desired value for each.

Here's a few sample cells, which all occur in the same column:

PTG X 4 / 60 MINS UNLD
85 MINS UNLD ( 1 HR 25 MINS)
50 MINS UNLD
DEL APPT / 29 MINS UNLD


<tbody>
</tbody>

<tbody>
</tbody>

<tbody>
</tbody>

<tbody>
</tbody>
So sometimes the desired information occurs at the beginning (85). sometimes it's in the middle (60, as in the first example). The other text varies, but the number always occurs just before the MIN or MINS text. In english my lgic is to find the position in the string in which the three letters MIN occur and then return the previous 4 characters (to cover those instances where both 2 or 3 digits occur); however, that's a problem when the number is 2 digits and occurs at the beginning of the string.

Thanks.
 
Upvote 0
The word MIN or MINS is always to the right of the number, and the number is always either 2 or 3 digits.
If the number is never a single digit, then would the word MIN (no "S") ever immediately follow your number?
 
Upvote 0
If the number is never a single digit, then would the word MIN (no "S") ever immediately follow your number?

The words MINS (including the S) is almost always used; I just wanted to cover the possibility that only MIN (without the S) might occur. These entries are manually entered notes, so it's possible that someone might fail to use the S.

The number is always 2 or 3 digits.

Thanks.
 
Upvote 0
Hi,

This should work for you:


Book1
ABC
1PTG X 4 / 60 MINS UNLD60
285 MINS UNLD ( 1 HR 25 MINS)85
3185 MINS UNLD ( 3 HR 5 MINS)185
450 MINS UNLD50
599MIN ABCD99
6DEL APPT / 29 MINS UNLD29
Sheet7
Cell Formulas
RangeFormula
C1=RIGHT(TRIM(LEFT(A1,SEARCH("MIN",A1)-1)),3)+0
 
Last edited:
Upvote 0
Hi,

This should work for you:

ABC
1PTG X 4 / 60 MINS UNLD60
285 MINS UNLD ( 1 HR 25 MINS)85
3185 MINS UNLD ( 3 HR 5 MINS)185
450 MINS UNLD50
599MIN ABCD99
6DEL APPT / 29 MINS UNLD29

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet7

Worksheet Formulas
CellFormula
C1=RIGHT(TRIM(LEFT(A1,SEARCH("MIN",A1)-1)),3)+0

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

It does, terrific. Thanks, jtakw, and also thanks to Rick Rothstein as well. This board and the people who respond to these questions are invaluable.
 
Upvote 0
It does, terrific. Thanks, jtakw, and also thanks to Rick Rothstein as well. This board and the people who respond to these questions are invaluable.
Just double checking as it could affect jtakw's formula... keeping in mind that we know nothing about your data, is it at all possible that the letters MIN might appear before the number you want? I am thinking of words like "MINI", "EXAMINE", and such.
 
Upvote 0
Just double checking as it could affect jtakw's formula... keeping in mind that we know nothing about your data, is it at all possible that the letters MIN might appear before the number you want? I am thinking of words like "MINI", "EXAMINE", and such.

No. fortunately the manual entry of these notes has proven to be very consistent.
 
Upvote 0
You're welcome, welcome to the forum, glad it worked for you.
 
Upvote 0

Forum statistics

Threads
1,215,143
Messages
6,123,274
Members
449,093
Latest member
Vincent Khandagale

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