Extracting phone number for each cell

ABBOTTS04

New Member
Joined
Jul 22, 2019
Messages
2
WHAT FORMULA WOULD WORK TO EXTACT JUST THE PHONE NUMBER FROM EACH CELL. IT STARTS WITH CELL A2

[TABLE="width: 1369"]
<colgroup><col></colgroup><tbody>[TR]
[TD]WCW ORGANIZATION INC. : Email- rooz51@gmail.com : Phone- 3108455117 [/TD]
[/TR]
</tbody>[/TABLE]

THANK YOU
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
WHAT FORMULA WOULD WORK TO EXTACT JUST THE PHONE NUMBER FROM EACH CELL. IT STARTS WITH CELL A2

[TABLE="width: 1369"]
<colgroup><col></colgroup><tbody>[TR]
[TD]WCW ORGANIZATION INC. : Email- rooz51@gmail.com : Phone- 3108455117 [/TD]
[/TR]
</tbody>[/TABLE]
One example is not usually all that all that helpful in describing one's data. For example, is the phone number always at the end of the text? Is the phone number always shown without dashes or parentheses? Does the word "Phone" alway precede the phone number? Along with many other questions as well...
 
Last edited:
Upvote 0
Good points Rick. More examples would be helpful. But, if your example is a good representation of what all of your data looks like, then this should do it.

Code:
Function PHONE(s As String) As String
Dim RX As Object: Set RX = CreateObject("VBScript.RegExp")
Dim pat As String: pat = "\d{10}"


With RX
    .Pattern = pat
    .Global = True
    .MultiLine = True
    .ignorecase = True
    PHONE = .Execute(s)(0)
End With


End Function
 
Upvote 0
Good points Rick. More examples would be helpful. But, if your example is a good representation of what all of your data looks like, then this should do it.

Code:
Function PHONE(s As String) As String
Dim RX As Object: Set RX = CreateObject("VBScript.RegExp")
Dim pat As String: pat = "\d{10}"


With RX
    .Pattern = pat
    .Global = True
    .MultiLine = True
    .ignorecase = True
    PHONE = .Execute(s)(0)
End With


End Function
If you assume the example is a good representation, then I would suggest this function instead :diablo:
Code:
Function PHONE(S As String) As String
  PHONE = Right(S, 10)
End Function
Hence, my questions.
 
Upvote 0
One example is not usually all that all that helpful in describing one's data. For example, is the phone number always at the end of the text? Is the phone number always shown without dashes or parentheses? Does the word "Phone" alway precede the phone number? Along with many other questions as well...

[TABLE="width: 1369"]
<colgroup><col></colgroup><tbody>[TR]
[TD]WCW ORGANIZATION INC. : Email- rooz51@gmail.com : Phone- 3108455117 [/TD]
[/TR]
[TR]
[TD]420 FOR THE PEOPLE COOPERATIVE INC : Stash Studio City : Email- 420forthepeople@gmail.com : Phone- 8188105353 [/TD]
[/TR]
[TR]
[TD]POINT BAY DISTRIBUTORS, LLC : Point Bay Distributors, LLC : Email- info@pointbaydist.com : Phone- 8505103483 : Website- https://www.pointbaydist.com/[/TD]
[/TR]
[TR]
[TD]KALI BOTANICALS : Kali Botanicals : Email- kalibotanicals213@gmail.com : Phone- 9512646666 [/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
[TABLE="width: 1369"]
<colgroup><col></colgroup><tbody>[TR]
[TD]WCW ORGANIZATION INC. : Email- rooz51@gmail.com : Phone- 3108455117 [/TD]
[/TR]
[TR]
[TD]420 FOR THE PEOPLE COOPERATIVE INC : Stash Studio City : Email- 420forthepeople@gmail.com : Phone- 8188105353 [/TD]
[/TR]
[TR]
[TD]POINT BAY DISTRIBUTORS, LLC : Point Bay Distributors, LLC : Email- info@pointbaydist.com : Phone- 8505103483 : Website- https://www.pointbaydist.com/[/TD]
[/TR]
[TR]
[TD]KALI BOTANICALS : Kali Botanicals : Email- kalibotanicals213@gmail.com : Phone- 9512646666 [/TD]
[/TR]
</tbody>[/TABLE]
It appears that your phone numbers are always 10 digits long with no dashes or parentheses and always follow the text "Phone- ". You could use the function that lrobbo314 posted, but another function that would also work is this...
Code:
Function PHONE(s As String) As String
  PHONE = Left(Split(s, "Phone- ")(1), 10)
End Function
 
Upvote 0
@Rick
I've never seen / noticed that before ???
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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