Clean up List of Phone Numbers

jleasure457

New Member
Joined
Dec 27, 2018
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hello, I am working on a formula to clean up a list of phone numbers with very inconsistent formats to all include just the 3 digit area code and following 7 digits. I have a formula that removes all spaces and non-numeric characters, but I can't figure out what I need to add that would remove extensions at the end of the phone number or country codes at the beginning.. I am using: =TEXTJOIN("",TRUE, IFERROR(MID(A2, ROW(INDIRECT("1:100")),1)+0,"")) , and this is the result. If this could be better accomplished with a macro, that would be acceptable as well. Any help would be appreciated!

Original Phone NumberNumber after Formula Applied
(999) 832-7870 (Mobile)9998327870
999-995-14559999951455
1-999-525-704519995257045
(999) 864-3091 ext. 3137 (Direct)99986430913137
(999) 526-3058 (Direct)9995263058
(999) 549-8913 (HQ)9995498913
+1 (999) 774-604119997746041
999-434-7736, ext 315899943477363158
(999) 422-8579 x902899942285799028
+44 (999) 774-6041449997746041
+339997746041339997746041
 
@JEC
You are right. Misread the requirement. Will spend a bit of time reworking. Thanks for pointing that out.
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Corrected Code
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Custom1 = Table.TransformColumns(Source,
     {{"Original Phone Number", each Text.Replace(Text.Replace(_, "(", ""), ")", ""),"-",""}}),
    #"Added Custom" = Table.AddColumn(Custom1, "Custom", each List.Accumulate(

    List.Numbers(0, Table.RowCount(Corrections)),
    [Original Phone Number],
    (A,B) =>
    Text.Replace(A,Corrections[Find]{B}, Corrections[Replace]{B}))),
    #"Replaced Value" = Table.ReplaceValue(#"Added Custom"," ","",Replacer.ReplaceText,{"Custom"}),
    #"Split Column by Character Transition" = Table.SplitColumn(#"Replaced Value", "Custom", Splitter.SplitTextByCharacterTransition({"0".."9"}, (c) => not List.Contains({"0".."9"}, c)), {"Custom.1", "Custom.2", "Custom.3"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Split Column by Character Transition",{"Custom.1"}),
    Trim= Test.End("Custom.1,10)
in
    Trim
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,194
Members
452,616
Latest member
intern444

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