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:

[TABLE="width: 197"]
<tbody>[TR]
[TD]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. [/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Here is a sample string from a cell in my spreadsheet:

[TABLE="width: 197"]
<tbody>[TR]
[TD]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. [/TD]
[/TR]
</tbody>[/TABLE]
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:

[TABLE="width: 197"]
<tbody>[TR]
[TD]PTG X 4 / 60 MINS UNLD
[TABLE="width: 383"]
<tbody>[TR]
[TD]85 MINS UNLD ( 1 HR 25 MINS)
[TABLE="width: 383"]
<tbody>[TR]
[TD]50 MINS UNLD
[TABLE="width: 383"]
<tbody>[TR]
[TD]DEL APPT / 29 MINS UNLD

[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
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
PTG X 4 / 60 MINS UNLD
85 MINS UNLD ( 1 HR 25 MINS)
185 MINS UNLD ( 3 HR 5 MINS)
50 MINS UNLD
99MIN ABCD
DEL APPT / 29 MINS UNLD

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]
[TD="align: right"]60[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"][/TD]
[TD="align: right"]85[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"][/TD]
[TD="align: right"]185[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"][/TD]
[TD="align: right"]50[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"][/TD]
[TD="align: right"]99[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"][/TD]
[TD="align: right"]29[/TD]

</tbody>
Sheet7

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C1[/TH]
[TD="align: left"]=RIGHT(TRIM(LEFT(A1,SEARCH("MIN",A1)-1)),3)+0[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

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,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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