Search code examples
excelphone-number

Find phone number along with its city code in excel


I Have some address from which I need to extract phone number along with its city code. Here is the column

A
T.C-29-877 (2), CPRA 0124-414210 mob:8578451021
T-Win Park,Westside 211-1421522 fgas-14201
Whitefield, rose bunglow 01221-2102125
Q-Part,bilmore,521-145212 abc@gmail.com

Here I want to extract

0124-414210
211-1421522
01221-2102125
521-145212

I tried with seperating with the delim - but since there can be multiple - in a text so it didn't worked for me.

Is there any which can be used to extract these values? Any help would be appreciated.

Thanks

Domnick


Solution

  • Assuming the data is in cell A1 try following array formula which needs to be committed by pressing CTRL+SHIFT+ENTER. And then copy down.

    =TRIM(MID(SUBSTITUTE(TRIM(SUBSTITUTE(A1,",",REPT(" ",199)))," ",REPT(" ",199)),SEARCH(MAX(IFERROR(-(MID(A1,ROW($A$1:$A$256),COLUMN($A$1:$IV$1)))+0,0)),SUBSTITUTE(TRIM(SUBSTITUTE(A1,",",REPT(" ",199)))," ",REPT(" ",199)),1)-99,199))

    If applied correctly Excel will wrap formula with braces.