Need to format telephone numbers into 10 digit number only.

tamwink

New Member
Joined
Dec 19, 2019
Messages
11
Office Version
  1. 365
Platform
  1. Windows
How do I remove the country codes, hyphens, and "+1" from a column of data?
All information appreciated.
 
That formula will not "Change" anything, it will simply take the value in A2 & show a modified version in the cell with the formula.
Dies it give you the correct value, as shown in post#4?
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
CITY​
STATE​
PHONE​
WhitingNJ‭+1 (704) 806-3506‬
Kendall ParkNJ024 0608 8588
Kendall ParkNJ030 377 1554
Kendall ParkNJ06-687 5888
Kendall ParkNJ0757 7192169
LakewoodNJ08503 810221
LakewoodNJ0910 830 3999
LakewoodNJ0917 535 9028
LakewoodNJ0929 035 6104
WhitingNJ095 935 6565
WhitingNJ1 512 473-2305
WhitingNJ1 585-258-3696
WhitingNJ1-(626) 539-0548
BeaufortSCp:+1(602) 7054282
AllendaleSCp:+1(612) 750-9273
SumterSCp:+1(770) 362-2000
AtlantaGAp:+1(979) 665-5052
AtlantaGAp:+117579209003
AtlantaGAp:+118014727251
Salt Lake CityUT954 793-1073
Salt Lake CityUT954 805-0608
West Valley CityUT954 805-6295
DraperUT954 805-7107
s.l.c.UT954 812-9849
Salt Lake CityUT954 815-4878
VernalUT954 815-5773
Salt Lake CityUT954 817-7959
Salt Lake CityUT954 821-3795
BountifulUT954 821-4484
 
Upvote 0
or try Power Query (Get&Transform)

rawgaaapPhoneNumbers
17206292779,7206292779
1-678-416-8080,6784168080
1(334) 662-9740,3346629740
p:+1175792090037579209003

Code:
// ExtractPhoneNumber
let
    Text = Table.AddColumn(Excel.CurrentWorkbook(){[Name="Table1"]}[Content], "PhoneNumbers", each Text.Combine(List.RemoveItems(Text.ToList([raw]),{" ","a".."z","-",".","+","(",")",",",":"}))),
    Result = Table.SelectColumns(Table.TransformColumns(Text, {{"PhoneNumbers", each Text.End(_, 10), type text}}),{"PhoneNumbers"})
in
    Result
 
Upvote 0
I don't know how to use Power Query (Get&Transform). Thanks for trying to help me. :)
 
Upvote 0
Select your range then use From Table (Data tab), it will open PowerQuery Editor, find Advanced Editor and paste there code copied from here
Make sure the name of the source table is the same as is in the code, here is: Table1

CITYSTATEPHONEgaaapNumbers
WhitingNJ‭+1 (704) 806-35067048063506
Kendall ParkNJ024 0608 85882406088588
Kendall ParkNJ030 377 1554303771554
Kendall ParkNJ06-687 588866875888
Kendall ParkNJ0757 71921697577192169
LakewoodNJ08503 8102218503810221
LakewoodNJ0910 830 39999108303999
LakewoodNJ0917 535 90289175359028
LakewoodNJ0929 035 61049290356104
WhitingNJ095 935 6565959356565
WhitingNJ1 512 473-23055124732305
WhitingNJ1 585-258-36965852583696
WhitingNJ1-(626) 539-05486265390548
BeaufortSCp:+1(602) 70542826027054282
AllendaleSCp:+1(612) 750-92736127509273
SumterSCp:+1(770) 362-20007703622000
AtlantaGAp:+1(979) 665-50529796655052
AtlantaGAp:+1175792090037579209003
AtlantaGAp:+1180147272518014727251
Salt Lake CityUT954 793-10739547931073
Salt Lake CityUT954 805-06089548050608
West Valley CityUT954 805-62959548056295
DraperUT954 805-71079548057107
s.l.c.UT954 812-98499548129849
Salt Lake CityUT954 815-48789548154878
VernalUT954 815-57739548155773
Salt Lake CityUT954 817-79599548177959
Salt Lake CityUT954 821-37959548213795
BountifulUT954 821-44849548214484

(this add-in doesn't work well, sometimes removing leading zeroes :( )
should be:
numbers.jpg


Code:
// ExtractPhoneNumber
let
    Raw = Table.TransformColumnTypes(Table.SelectColumns(Excel.CurrentWorkbook(){[Name="Table1"]}[Content],{"PHONE"}),{{"PHONE", type text}}),
    Text = Table.AddColumn(Raw, "Numbers", each Text.Combine(List.RemoveItems(Text.ToList([PHONE]),{" ","a".."z","-",".","+","(",")",",",":","("}))),
    Result = Table.SelectColumns(Table.TransformColumns(Text, {{"Numbers", each Text.End(_, 10), type text}}),{"Numbers"})
in
    Result

worth to read :)
 
Last edited:
Upvote 0
I keep getting an error message.
This appears where I need to insert your code. Do I keep this text and add your code?
1576797597233.png
 
Upvote 0
no, replace existing code with code from the last post then OK, then Close&Load

btw. why your pics are so big ?
 
Upvote 0

Forum statistics

Threads
1,223,671
Messages
6,173,725
Members
452,529
Latest member
jpaxonreyes

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