Find phone number along with its city code in excel - 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

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.

Related

How to use MID, RIGHT and FIND functions in Excel?

I am trying to combine the State (NSW) and the Postal Code (2007) from cell F4 in the worksheet "Inventory", this is the text in cell F4: 310 Wattle StUltimo, 2007, NSW
What I trying to accomplish is this: NSW2007 using MID, RIGHT and FIND functions, but is giving me a headache
I tried this: =RIGHT(Inventory!F4,4) and I got so far this: NSW, what I need to get is NSW2007 so I am missing the MID (and FIND) part
thanks for your help in advance
With Office 365:
=LET(
rr,F4,
x,TRIM(TEXTSPLIT(rr,",")),
CONCAT(INDEX(x,COUNTA(x)-{0,1})))
For Older versions:
=TRIM(RIGHT(SUBSTITUTE(F4,",",REPT(" ",999)),999))&
TRIM(MID(SUBSTITUTE(F4,",",REPT(" ",999)),(LEN(F4)-LEN(SUBSTITUTE(F4,",",""))-1)*999,999))
If there is always only 2 , in the string and you want the 3rd and 2nd then we can simplify the above formula:
=LET(
rr,F4,
x,TRIM(TEXTSPLIT(rr,",")),
CONCAT(INDEX(x,{3,2})))
And
=TRIM(RIGHT(SUBSTITUTE(F4,",",REPT(" ",999)),999))&
TRIM(MID(SUBSTITUTE(F4,",",REPT(" ",999)),999,999))
I used the following Excel text formula.
Using the text in F4: "310 Wattle StUltimo, 2007, NSW"
To get NSW2007 from the text in F4 above use the following formula.
=CONCAT(TRIM(MID(F4,FIND(",",F4,FIND(",",F4,1)+1)+1,LEN(F4))),TRIM(MID(F4,FIND(",",F4,1)+1,FIND(",",F4,FIND(",",F4,1)+1)-FIND(",",F4,1)-1)))
To get NSW: =MID(F4,FIND(",",F4,FIND(",",F4,1)+1)+1,LEN(F4))
To get 2007: =MID(F4,FIND(",",F4,1)+1,FIND(",",F4,FIND(",",F4,1)+1)-FIND(",",F4,1)-1)
Then concatenate the two: concat (formula 1 above, formula 2 above).
This formula works regardless of the spaces (or no spaces at all) before and after the commas.
Hope this helps.

extract email from column

Trying to extract the email from a column in an excel sheet using the following formula:
=TRIM(MID(SUBSTITUTE(" "&$A1&" "," ",REPT(" ",40)),
FIND(REPT("#",COLUMNS($A1:A1)),SUBSTITUTE
(SUBSTITUTE(" "&$A1&" "," ",REPT(" ",40)),"#",REPT("#",COLUMNS($A1:A1)),COLUMNS($A1:A1)))-40,80))
The formula works for the most part, however some of the records still include other text.
For example, one of the records looks like this:
**TEST** John Beasley,jbeasley#usa.com,7575551212
After using the above formula, I get the following results:
Beasley,jbeasley#usa.com,7575551212
Here's another example:
USA-USA/J Beasley/jbeasley#usa.com/757-555-1212
Results after using formula:
Beasley/jbeasley#usa.com/757-555-1212
Here is an example of when the formula works (before):
**US AMA TES DATA** John Beasley, jbeasley#usa.com
Which yields the following results:
jbeasley#usa.com
So the formula works, but it also does not work.
How can I write the formula so that it extracts everything except the actual email address?
If one has it, use FILTERXML:
=FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(A1,"/",","),",","</s><s>")&"</s></t>","//s[contains(.,'#')]")
FILTERXML was introduced in Excel 2013 and only on PC not Mac.
If does not have FILTERXML then we can use:
=TRIM(MID(SUBSTITUTE(SUBSTITUTE(A1,"/",","),",",REPT(" ",999)),FIND("#",SUBSTITUTE(SUBSTITUTE(A1,"/",","),",",REPT(" ",999)))-500,999))

How can I add a comma & space after every two digits in Excel and then format the text?

Here's the table I'm working with:
First off, how can I separate the string of numbers in column C so that they have a comma and space after every two digits?
I was able to partially finish it, but for some reason I can't grab the last two digits. I used this formula:
=MID(C4,1,2)&", "&MID(C4,3,2)&", "&MID(C4,6,2)&", "&MID(C4,10,2)&", "&MID(C4,13,2)&", "&MID(C4,16,2)
After that I need to somehow format that string to look like the example in column E, that's where I'm really confused. Maybe I don't even need the first step?
Any help is appreciated. Thanks
If you already have access to TEXTJOIN formula then it will quickly become your best friend :-)
I assume that your values are in column C (starting from cell C1) and that the column is formatted as text.
Try:
="""stats"":["&TEXTJOIN(", ",TRUE,MID(C1,ROW($A$1:INDEX(A:A,LEN(C1)/2))*2-1,2))&"]"
If your Office 365 version is not using dynamic arrays yet, try entering the formula with Ctrl+Shift+Enter:

Turn '=IF(ISNUMBER(SEARCH')' answer into numeric instead of text (to use autosum)

I'm trying to get Excel to work out if a cell contains a certain courier company (DHL, DPD etc) and I want it to give out the number of miles to the nearest drop-off point. It works but it gives me a text answer instead of a number, this means autosum won't work. How do I change the code to give a numeric answer? Cheers Brian
=IF(
ISNUMBER(SEARCH("collect",Q2,1))=TRUE,"1",
IF(ISNUMBER(SEARCH("dhl",Q2,1))=TRUE,"2.6",
IF(ISNUMBER(SEARCH("DPD",Q2,1))=TRUE,"1",
IF(ISNUMBER(SEARCH("inpost",Q2,1))=TRUE,"1.2",
IF(ISNUMBER(SEARCH("hermes",Q2,1))=TRUE,"0.6",
IF(ISNUMBER(SEARCH("royal",Q2,1))=TRUE,"0.5",
IF(ISNUMBER(SEARCH("force",Q2,1))=TRUE,"0.5",
IF(ISNUMBER(SEARCH("ups",Q2,1))=TRUE,"0.6",
IF(ISNUMBER(SEARCH("yodel",Q2,1))=TRUE,"0",
IF(ISNUMBER(SEARCH("collection",Q2,1))=TRUE,"0",
"No"))
=IF
(ISNUMBER(SEARCH("collection",Q2,0))=TRUE,1,
IF(ISNUMBER(SEARCH("dhl",Q2,1))=TRUE,2.6,
IF(ISNUMBER(SEARCH("DPD",Q2,1))=TRUE,1,
IF(ISNUMBER(SEARCH("inpost",Q2,1))=TRUE,1.2,
IF(ISNUMBER(SEARCH("hermes",Q2,1))=TRUE,0.6,
IF(ISNUMBER(SEARCH("royal",Q2,1))=TRUE,0.5,
IF(ISNUMBER(SEARCH("force",Q2,1))=TRUE,0.5,
IF(ISNUMBER(SEARCH("ups",Q2,1))=TRUE,0.6,
IF(ISNUMBER(SEARCH("yodel",Q2,1))=TRUE,0,
0))))))))
If I followed your question correctly, this should work.
It has the advantage that you can extend the list easily to add other transporters and update distances.
You could use index() with match() in cell B3 instead of vlookup if you wish:
=IFERROR(INDEX($E$5:$E$13,MATCH(A3,$D$5:$D$13,0)),"not in list")
I used data validation to pick from the list in cell A3.
I just copied your formula in accordance with the comments, and removed =TRUE:
=IF
(ISNUMBER(SEARCH("collection",Q2,1)),1,
IF(ISNUMBER(SEARCH("dhl",Q2,1)),2.6,
IF(ISNUMBER(SEARCH("DPD",Q2,1)),1,
IF(ISNUMBER(SEARCH("inpost",Q2,1)),1.2,
IF(ISNUMBER(SEARCH("hermes",Q2,1)),0.6,
IF(ISNUMBER(SEARCH("royal",Q2,1)),0.5,
IF(ISNUMBER(SEARCH("force",Q2,1)),0.5,
IF(ISNUMBER(SEARCH("ups",Q2,1)),0.6,
IF(ISNUMBER(SEARCH("yodel",Q2,1)),0,
0))))))))

Excel - Converting Text in a result

I'm looking for some tips to transform a result I have in a cell from text to long.
In Cell A1 I have : "8 days 5 hours 10 minutes"
In cell B1 I have : "8*86400+5*3600+10*60" which I have with some "substitue"'s function
here is the function : ""=SUBSTITUE(SUBSTITUE(SUBSTITUE(SUBSTITUE(A1;" days";"*86400");" hours";"*3600");" minutes";"*60");" ";"+")""
In cell C1 i would like the result
My problem is I need this "8*86400+5*3600+10*60" to be "709800", and I can't find a way to reach it.
I thought it was about formating my cells but I tried everything and it didn't worked.
I can bet I tried all excel functions...
I'm stuck actually and looking for some good ideas.
Thank you for your help or advices !
File_picture
Here is a formula to perform the calculation from your string. It relies on the format as you have above, with a single space between each item in the string.
=SUMPRODUCT(--TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",99)),{1,198,396},99)),{86400,3600,60})
The formula creates an array of the relevant values, and then applies the appropriate multiplier.
If there might be more than one space between each segment, then use:
=SUMPRODUCT(--TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",99)),{1,198,396},99)),{86400,3600,60})

Resources