+ Reply to Thread
Results 1 to 10 of 10

Thread: phone number formate

  1. #1
    Registered User
    Join Date
    10-29-2010
    Location
    pakistan
    MS-Off Ver
    Excel 2003
    Posts
    3

    Red face phone number formate

    Some of the numbers in my csv file with only phone numbers look like;

    "(111)--111-1111"

    and some look like;

    "111-111-1111"


    Is there a command or function or rule format we can tell the .CSV document to follow to get all the lines to follow the same format style

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: phone number formate

    Hello akhter1987,

    Welcome to the Forum!

    Try this first...
    1. Right Click the cell and choose Format Cells...
    2. Under Category click Special
    3. In the Type box click Phone Number
    4. Finally select your Locale from the drop down
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    10-29-2010
    Location
    pakistan
    MS-Off Ver
    Excel 2003
    Posts
    3

    Angry Re: phone number formate

    Quote Originally Posted by Leith Ross View Post
    Hello akhter1987,

    Welcome to the Forum!

    Try this first...
    1. Right Click the cell and choose Format Cells...
    2. Under Category click Special
    3. In the Type box click Phone Number
    4. Finally select your Locale from the drop down
    new to excel don't know these terms

  4. #4
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: phone number formate

    What terms?
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  5. #5
    Forum Guru Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    5,590

    Re: phone number formate

    Does this work for anything other than English(United States)?

  6. #6
    Registered User
    Join Date
    10-29-2010
    Location
    pakistan
    MS-Off Ver
    Excel 2003
    Posts
    3

    Red face Re: phone number formate

    Quote Originally Posted by royUK View Post
    What terms?


    mean i tried this but its not working what i explain i am using excel 2007

  7. #7
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,006

    Re: phone number formate

    The phone format tends to be US based as all numbers follow the same format!

    UK numbers have variable length STD codes 01706-xxxxxx 0161 xxx-xxxx it gets complicated!
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  8. #8
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: phone number formate

    There's not a Special Format for UK based phone numbers, so I think you need to create your own Custom Format.

    The numbers in the examole look like they may be text though. It may be simpler to use Find & Replace for the brackets
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  9. #9
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,006

    Re: phone number formate

    I suppose the question is what format do you want them in!

    the easiest way is to strip out the junk and then re-build the format you want, I am wary about the number formatting option, simply because of leading 0's

    =TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"(",""),")",""),"-","")," ",""),"(000)-000-0000")

    should cope with the formats you have above and output them as a text string!

    Put the formula in a helper column, you can then highlight them and cut and paste using paste special>values, over the originals
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  10. #10
    Forum Guru Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    5,590

    Re: phone number formate

    Maybe this UDF (user defined function)
    Option Explicit
    
    Function ReturnAllDigits(ByVal rng, Optional Separator As String = " ")
        Dim n As Integer
        Dim arrDigits As Variant
    
        ReturnAllDigits = ""
    
        For n = 1 To Len(rng)
            If Asc(Mid(rng, n, 1)) < 48 Or Asc(Mid(rng, n, 1)) > 57 Then
                Mid(rng, n, 1) = " "
            End If
        Next
    
        arrDigits = Split(WorksheetFunction.Trim(rng), " ")
        For n = LBound(arrDigits) To UBound(arrDigits)
            If n < UBound(arrDigits) Then
                ReturnAllDigits = ReturnAllDigits & arrDigits(n) & Separator
            Else
                ReturnAllDigits = ReturnAllDigits & arrDigits(n)
            End If
        Next
    
    End Function

    To use this
    1/. With Excel open Press Alt+f11 this will open the VBa Editor.
    2/. In the VBa editor Insert > Module
    3/. Paste all of the above code in the resultant pane/window.
    4/. Save and close the VBa Editor.

    5/. Enter the formula so, if you want to specify a separator
    =ReturnAllDigits(A2,"-")

    or to accept the default separator (Space)
    =ReturnAllDigits(A2)

    This will extract the phone number from any string, provided there are no other numbers in the string.

    If you can't leave a macro in your workbook then Copy the result and PasteSpecial > Values this will remove the underlying function. You can then remove the code, either Export and Save the module or Delete it if you no longer need it.

    Hope this helps
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However, if this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody! ....
    Also
    If you are satisfied by any members response to your problem please consider using the small Star icon botom left of thier post to show your appreciation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0