How do I create a phone number format with only dashes and numbers

Anonymous
2018-11-14T14:48:05+00:00

I am trying to create a phone number format with only numbers and dashes.  I have a file with phone numbers formatted as (###) ###-####.  I want to reformat to ###-###-####.  I tried and the attached screen shot does not work.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Jim G 134K Reputation points MVP Volunteer Moderator
    2018-11-17T15:58:44+00:00

    This is so simple to do. No macros are needed.

    In the column next to the column you want to format, enter the phone number in the desired format and press return. Then press Control-e to invoke Flash Fill. The column will fill with the proper formatting.

    7 people found this answer helpful.
    0 comments No comments

16 additional answers

Sort by: Most helpful
  1. Anonymous
    2018-11-14T23:06:08+00:00

    Bernie, See column J Phone field--here is the link:

    Member file

    0 comments No comments
  2. Anonymous
    2018-11-15T15:52:32+00:00

    Your problem is exactly what I described - your entries have (  ) - and spaces so they are strings, not numbers.

    Run this macro with that sheet active to fix everything:

    Sub FixPhoneNumbers()

        With Range("J:K")

        .NumberFormat = "###-###-####"

        .Replace What:=")", Replacement:="", LookAt:=xlPart

        .Replace What:="(", Replacement:="", LookAt:=xlPart

        .Replace What:="-", Replacement:="", LookAt:=xlPart

        .Replace What:=" ", Replacement:="", LookAt:=xlPart

        .HorizontalAlignment = xlCenter

        End With

    End Sub

    0 comments No comments
  3. Anonymous
    2018-11-15T16:07:44+00:00

    Wow, this is above my pay grade.  I have the document open, where do I run the macro, in the sheet, in the active tab, or external.  The column headings are different in the second tab.  The first tab is the one I am most concerned with.

    0 comments No comments
  4. Anonymous
    2018-11-15T16:32:21+00:00

    Follow the instructions here:

    https://peltiertech.com/how-to-use-someone-elses-macro/

    To use the macro on another sheet (or tab as you call them), simply select a cell or cells with a phone number (or numbers) - in your example sheet, you could select cells J2 and K2 -  and run this version of the macro:

    Sub FixPhoneNumberss()

        With Selection.EntireColumn

        .NumberFormat = "###-###-####"

        .Replace What:=")", Replacement:="", LookAt:=xlPart

        .Replace What:="(", Replacement:="", LookAt:=xlPart

        .Replace What:="-", Replacement:="", LookAt:=xlPart

        .Replace What:=" ", Replacement:="", LookAt:=xlPart

        .HorizontalAlignment = xlCenter

        End With

    End Sub

    0 comments No comments