I have a unstructured data in some cells A1,A2,A3,A4 and want to extract mobile numbers in different cell
--------------------------(A)--------------------------
(1) `ABCDEFG CFGHJKL 9810642882 9212451029 9818682274`
(2) `ABCDERFT 9910077711 9811195125 9999966744`
(3) `ADFRTYU.9810851029 9818218521 9811056189`
(4) `ADFGT FTYUH 9873155802`
Result from cell A1:
----(A)--- ----(B)--- ----(C)---
(1) 9810642882 9212451029 9818682274
For a formula only solution, in cell B1 and copied over and down:
You can use Excel's built in "Text to Columns" functionality for this.
Highlight column
A
and go to Data>>Text To Columns. Choose "Delimited" and then "Space" as your delimiter. Click finish, and it will split the data by space and write it out to the adjacent columns.For a VBA UDF you can use the super handy
SPLIT()
string method which will split a string by a delimiter to an Array. Then just pick off the position you need:To use this in your worksheet:
Which will return the string at the first position of your
A1
value when split by space. If you put this inB1
then you could useColumn()
to make it more dynamic so you can just drag the formula right and down:Here is an edit to the above funcion that will split by the delim, and then rebuild an array with just the numeric values from the split, then output the token requested from the numeric array: