+ Reply to Thread
Results 1 to 6 of 6

Phone numbers

  1. #1
    Registered User
    Join Date
    06-26-2019
    Location
    Freeport, Tx
    MS-Off Ver
    Microsoft 2016 32-bit
    Posts
    32

    Phone numbers

    My source workbook has a customer list with phone numbers.

    I am writing a VBA program in another workbook to look up these phone numbers. My problem is that the phone numbers were keyed in by different people in different formats (234) 567-7890 and 234-567-7890 and even 234 567-7890.

    I need to convert these to just a 10 digit string 2345677890 regardless of the original format. I found some code that with read each character and determine if it is a number, but I wanted to know if there was something less complicated.

    Thank you.

  2. #2
    Valued Forum Contributor
    Join Date
    11-02-2016
    Location
    NY
    MS-Off Ver
    2010
    Posts
    459

    Re: Phone numbers

    you could do a search and replace of the characters ( "(", ")", "-", " ") with nothing...make it a text field! ( I use Ctrl+H ~ shortcut key)

  3. #3
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Phone numbers

    Hi
    what about
    Please Login or Register  to view this content.
    You Data in A2 down
    Last edited by mohadin; 12-06-2019 at 05:06 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Phone numbers

    This can be done. The question is what do you want done if the input can not be converted to a 10 digit string? If you strip out non-numeric characters and the result is not equal to 10 digits, do you want to return the original input? (to avoid risk of losing data) or to return null? (prefer to lose any input if it doesn't meet desired output criteria)

    Please Login or Register  to view this content.
    Above is a function to check any string input and return a 10 digit numeric string.

    If it is unable to convert, it will return the original input.

    (If you would prefer not to return data on fail, change the
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    )
    Last edited by mc84excel; 12-06-2019 at 07:29 PM. Reason: correct Like
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Phone numbers

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: Phone numbers

    Administrative Note:

    We would very much like to help you with your query, however the thread title does not really convey what your request is about.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Phone number format - reference post (Formatting Textbox to type phone numbers only)
    By eddyrcabrera79 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-01-2015, 05:35 PM
  2. Replies: 8
    Last Post: 11-19-2014, 06:12 PM
  3. Phone Numbers
    By LS Flowers in forum Excel General
    Replies: 3
    Last Post: 02-17-2010, 11:19 AM
  4. Replies: 2
    Last Post: 06-23-2006, 02:00 PM
  5. [SOLVED] Convert phone numbers with dashes in them to just numbers
    By J H in forum Excel General
    Replies: 2
    Last Post: 06-22-2006, 09:45 PM
  6. phone numbers
    By Tony R in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 09-17-2005, 10:05 PM
  7. Replies: 1
    Last Post: 02-11-2005, 01:06 PM

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.6.0 RC 1