Extract information from cells

Mantiyeah

New Member
Joined
Sep 19, 2018
Messages
8
So I have a column with information like this:

XC-163 0827m Timber problems
0600m failed picture cv-76
ligts out 0987m p3
etc

What I need is to create a column only with the measurement info in it which goes behind the m, in this case:
0827
0600
0987

Any ideas of which functions I can use?

Thanks!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi,

Assuming what you want extracted is Always 4 character before "m", and in case it may be at the end of the text string:


Book1
AB
1XC-163 0827m Timber problems0827
20600m failed picture cv-760600
3ligts out 0987m p30987
4some other text 0123m0123
Sheet309
Cell Formulas
RangeFormula
B1=RIGHT(LEFT(A1,SEARCH("m ",A1&" ")-1),4)
 
Upvote 0
Those will have problems if any other text before the measurement ends in an m and a space

This UDF may help:
Code:
Function GetMeasurement(r As String) As String
Dim x As Long
For x = 1 To Len(r)
    If Mid(r, x, 5) Like "####m" Then GetMeasurement = Mid(r, x, 4): Exit Function
Next x
End Function


Excel 2010
AB
1XC-163 0827m Timber problems0827
20600m failed picture cv-760600
3ligts out 0987m p30987
4XC-163m 0827m Timber problems0827
Sheet1
Cell Formulas
RangeFormula
B1=GetMeasurement(A1)
B2=GetMeasurement(A2)
B3=GetMeasurement(A3)
B4=GetMeasurement(A4)
 
Last edited:
Upvote 0
Those will have problems if any other text before the measurement ends in an m and a space

This will "narrow" it down a bit, but Not if there's another set of Numbers with an m behind it:


Book1
AB
1XC-163 0827m Timber problems0827
20600m failed picture cv-760600
3ligts out 0987m p30987
4some other text 0123m0123
5from now to 0750m and after0750
Sheet309
Cell Formulas
RangeFormula
B1=RIGHT(LEFT(A1,SEARCH("m ",A1&" ",MIN(FIND({0,1,2,3,4}+{0;5},A1&1/17)))-1),4)
 
Last edited:
Upvote 0
I'm glad you thought of a formula solution but how does my UDF differ from your formula results?


Excel 2010
ABC
1XC-163 0827m Timber problems 0425m08270827
20600m failed picture cv-7606000600
3ligts out 0987m p309870987
4some other text 0123m01230123
5from now to 0750m and after07500750
Sheet1
Cell Formulas
RangeFormula
B1=RIGHT(LEFT(A1,SEARCH("m ",A1&" ",MIN(FIND({0,1,2,3,4}+{0;5},A1&1/17)))-1),4)
B2=RIGHT(LEFT(A2,SEARCH("m ",A2&" ",MIN(FIND({0,1,2,3,4}+{0;5},A2&1/17)))-1),4)
B3=RIGHT(LEFT(A3,SEARCH("m ",A3&" ",MIN(FIND({0,1,2,3,4}+{0;5},A3&1/17)))-1),4)
B4=RIGHT(LEFT(A4,SEARCH("m ",A4&" ",MIN(FIND({0,1,2,3,4}+{0;5},A4&1/17)))-1),4)
B5=RIGHT(LEFT(A5,SEARCH("m ",A5&" ",MIN(FIND({0,1,2,3,4}+{0;5},A5&1/17)))-1),4)
C1=GetMeasurement(A1)
C2=GetMeasurement(A2)
C3=GetMeasurement(A3)
C4=GetMeasurement(A4)
C5=GetMeasurement(A5)
 
Upvote 0
What is the purpose of the 1/17?

EDIT: I think I figured it out. It's a decimal number that contains all the digits 0-9. Clever!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,190
Messages
6,123,547
Members
449,107
Latest member
caya

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