any one correct this single formula to extract 10 digits mobile number

Prasad K

Board Regular
Joined
Aug 4, 2021
Messages
189
Office Version
  1. 2016
  2. 2007
Platform
  1. Windows
this single formula is working there is a problem this formula is extracting only one 10 digit Mobile from starting i want to extract all 10 digit number to separate cells


=MID($A$1,(FIND("Phone:",$A$1)+LEN("Phone:"))+1,(FIND(" ",$A$1,(FIND("Mobile:",$A$1)+LEN("Mobile:"))+1)-(FIND("Mobile:",$A$1)+LEN("Mobile:")+1)))



dup.xlsm
ABCDE
1prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870963258741096325874109632587410
2prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870963258741096325874109632587410
3prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870 bobby Phone: 74136985219632587410963258741096325874109632587410
Sheet5
Cell Formulas
RangeFormula
B1:D1B1=MID($A$1,(FIND("Phone:",$A$1)+LEN("Phone:"))+1,(FIND(" ",$A$1,(FIND("Mobile:",$A$1)+LEN("Mobile:"))+1)-(FIND("Mobile:",$A$1)+LEN("Mobile:")+1)))
B3:E3,B2:D2B2=MID($A$2,(FIND("Phone:",$A$2)+LEN("Phone:"))+1,(FIND(" ",$A$2,(FIND("Mobile:",$A$2)+LEN("Mobile:"))+1)-(FIND("Mobile:",$A$2)+LEN("Mobile:")+1)))
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try this

21 09 05.xlsm
ABCDEF
1prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870963258741085214796306541239870  
2prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870963258741085214796306541239870  
3prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870 bobby Phone: 74136985219632587410852147963065412398707413698521 
Phone
Cell Formulas
RangeFormula
B1:F3B1=LEFT(TRIM(MID(SUBSTITUTE(SUBSTITUTE($A1,"Mobile","Phone"),"Phone: ",REPT(" ",100)),100*COLUMNS($B:B),100)),10)
 
Upvote 0
Try this

21 09 05.xlsm
ABCDEF
1prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870963258741085214796306541239870  
2prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870963258741085214796306541239870  
3prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870 bobby Phone: 74136985219632587410852147963065412398707413698521 
Phone
Cell Formulas
RangeFormula
B1:F3B1=LEFT(TRIM(MID(SUBSTITUTE(SUBSTITUTE($A1,"Mobile","Phone"),"Phone: ",REPT(" ",100)),100*COLUMNS($B:B),100)),10)
Thank you Peter working perfectly

one more small doubt why my formula is extracting only one mobile number
 
Upvote 0
Thank you Peter working perfectly
You're welcome.

one more small doubt why my formula is extracting only one mobile number
In every cell your formula is finding the first "Phone:" then starts 7 characters after that and goes until it finds a space. That would always be the first 'Phone" number.
There is another unrelated error in that your row 3 formula is actually extracting the first number from the row 2 data.
 
Upvote 0
You're welcome.


In every cell your formula is finding the first "Phone:" then starts 7 characters after that and goes until it finds a space. That would always be the first 'Phone" number.
There is another unrelated error in that your row 3 formula is actually extracting the first number from the row 2 data.
oh Thank you

and more small help from you i got a vba function extract numbers here is a problem this function will extract all numbers into one column only kindly please i request you change this extract numbers into separate columns


dup.xlsm
AB
1prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobiles: 6541239870 bobby Phone: 7413698521 Reddy Mobile: 65412398719632587410 8521479630 6541239870 7413698521 6541239871
2prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobiles: 6541239870 bobby Phone: 7413698521 Reddy Mobile: 6541239871
Sheet6
Cell Formulas
RangeFormula
B1B1=StrPhone(A1)



VBA Code:
Function StrPhone(strIn As String) As String
    Dim objRegexp As Object
    Set objRegexp = CreateObject("VBScript.Regexp")
    With objRegexp
        .Global = True
        .Pattern = ".*?(\d{10})|.*$"
        StrPhone = Trim(.Replace(strIn, "$1 "))
    End With
End Function
 
Upvote 0
Here is one short formula
Code:
=LEFT(TRIM(MID(SUBSTITUTE(" " & $A1,": ",REPT(" ",100)),COLUMNS($B$1:B1)*100,100)),10)
 
Upvote 0
Here is one short formula
Code:
=LEFT(TRIM(MID(SUBSTITUTE(" " & $A1,": ",REPT(" ",100)),COLUMNS($B$1:B1)*100,100)),10)
Thankyou can you change above VBA function as per my request
 
Upvote 0
Here is one way with a UDF

VBA Code:
Function Phone(s As String, n As Long) As String
  With CreateObject("VBScript.RegExp")
    .Global = True
    .Pattern = "\d{10}"
    If n <= .Execute(s).Count Then Phone = .Execute(s)(n - 1)
  End With
End Function

Prasad K.xlsm
ABCDEF
1prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870963258741085214796306541239870  
2prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870963258741085214796306541239870  
3prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870 bobby Phone: 74136985219632587410852147963065412398707413698521 
Sheet1
Cell Formulas
RangeFormula
B1:F3B1=Phone($A1,COLUMNS($B:B))
 
Upvote 0
Solution
Here is one way with a UDF

VBA Code:
Function Phone(s As String, n As Long) As String
  With CreateObject("VBScript.RegExp")
    .Global = True
    .Pattern = "\d{10}"
    If n <= .Execute(s).Count Then Phone = .Execute(s)(n - 1)
  End With
End Function

Prasad K.xlsm
ABCDEF
1prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870963258741085214796306541239870  
2prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870963258741085214796306541239870  
3prasad Phone: 9632587410 vishnu Mobile: 8521479630 reddy Mobile: 6541239870 bobby Phone: 74136985219632587410852147963065412398707413698521 
Sheet1
Cell Formulas
RangeFormula
B1:F3B1=Phone($A1,COLUMNS($B:B))
Thankyou so much Peter
 
Upvote 0
You're welcome.

If you wanted a vba solution, I'm wondering why you didn't ask that in post 1 instead of giving us a worksheet formula and asking us to modify that? Would have saved considerable time and effort. :(
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,670
Members
449,248
Latest member
wayneho98

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