Format Phone Number to numbers only and according to country code

GTBsha

New Member
Joined
Aug 10, 2023
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
  2. MacOS
Hi everyone, got a file with a bunch of phone numbers how can I change the data into the following:
Automatically remove uneccesary details like parenthesis, spaces, dots or dashes and just convert it into numbers only
Add the country code
Avoid having duplicate country codes in the cell if phone number already contains a country code
 

Attachments

  • Screen Shot 2023-08-10 at 10.18.53 PM.png
    Screen Shot 2023-08-10 at 10.18.53 PM.png
    15.4 KB · Views: 7

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
this should work in v2019
Book1
ABCDE
1countrycountry codephonecountry codeoutput
2United StatesUS7832237455117832237455
3MexicoMX52 124 361 70525212436170
4CanadaCA1.613.284.5332116132845332
5AustaraliaAU1 8186877577616118186877577
6PhillippinesPH(985) 525899663639855258996
Sheet1
Cell Formulas
RangeFormula
E2:E6E2=CONCAT(IF(VALUE(LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C2," ",""),"-",""),"(",""),")",""),".",""),LEN(D2)))=D2,"",D2),SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C2," ",""),"-",""),"(",""),")",""),".",""))
 
Upvote 0
Solution

Forum statistics

Threads
1,215,125
Messages
6,123,195
Members
449,090
Latest member
bes000

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