Extracting numbers from a text string

Mike152

New Member
Joined
Jan 5, 2013
Messages
5
PROBLEM
I need to extract the Length and the Width (to do some calculations) of each product that comes through my system.

ANALYSIS
The data is held in one Excel cell and looks like this :-
(various lengths of data) – L1111m, W222mm, T33um – (other various lengths data)
or (various lengths of data) – L1m, W2222mm, T333um – (other various lengths data)
or (various lengths of data) – L11m, W2mm, T3333um – (other various lengths data)
or (various lengths of data) – L111m, W22mm, T3um – (other various lengths data)

EXAMPLES
1. Part 768/, - num 34sd23 - L5000m, W63mm, T7um, zxcv
2. Num345 /rt5, - London dfg87 - 4other4 - L250m, W1020mm, T341um, other data
In example 1, I want to end up with ‘5000’ and ‘63’ as numbers.
In example 2, I want to end up with ‘250’ and ‘1020’ as numbers.

POINTS
It’s always Length then Width (then Thickness)
The Length always starts with ‘space dash space L’ and ends with ‘m comma space W’
The Width always starts with ‘m comma space W’ and ends with ‘mm comma space T’
The Length Width (and Thickness) are usually at the very end of the data.

PROBLEMS
I’m having real problems defining the start and endpoint of the Length and Width values because of their variable positions and lengths.
I’ve tried using various combinations of ‘FIND‘, SEARCH’, ‘RIGHT‘, ‘MID‘, ‘LEFT‘, & ‘LEN‘ (and ‘HocusPocus‘ !) but I end up being totally confused and bewildered.

I regard myself as OK with Excel. I have created some complex formulas and I have helped others with their various Excel problems but this is absolutely frightful!

I would be very grateful for some help, thank you, Mike
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Mike, try each of these, copied down.


Book1
ABC
1(various lengths of data) L1111m, W222mm, T33um (other various lengths data)1111222
2or (various lengths of data) L1m, W2222mm, T333um (other various lengths data)12222
3lengths of data) L11m, W2mm, T3333um (other112
4data) L111m, W22mm, T3um (other various lengths data)11122
5Part 768/, - num 34sd23 - L5000m, W63mm, T7um, zxcv500063
6Num345 /rt5, - London dfg87 - 4other4 - L250m, W1020mm, T341um, other data2501020
L & W
Cell Formulas
RangeFormula
B1=RIGHT(SUBSTITUTE(LEFT(A1,SEARCH("m, W",A1)-1),"L",REPT(" ",20)),20)+0
C1=RIGHT(SUBSTITUTE(LEFT(A1,SEARCH("mm, T",A1)-1),"W",REPT(" ",20)),20)+0
 
Upvote 0
Peter, that woks a treat, absolutely splendid, thank you soooooo much.
I wouldn’t have thought of that in a month of Sundays!
I am very grateful indeed, thanks again, Best Wishes, Mike
 
Last edited:
Upvote 0
Peter, that woks a treat, absolutely splendid, thank you soooooo much.
I wouldn’t have thought of that in a month of Sundays!
I am very grateful indeed, thanks again, Best Wishes, Mike
You are very welcome. Glad to help. :)
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,319
Members
449,218
Latest member
Excel Master

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