+ Reply to Thread
Results 1 to 11 of 11

Formatting Textbox to type phone numbers only

  1. #1
    Registered User
    Join Date
    12-02-2013
    Location
    Miami
    MS-Off Ver
    Excel 2010
    Posts
    89

    Formatting Textbox to type phone numbers only

    Hi,

    I have a Textbox called PhoneNumber and I want to be able only to enter the phone number in this format ###-###-#### and if for some reason I enter a letter or another symbol I want to receive a notification saying "Please enter numbers only"

    I was trying to put together 2 codes and so far, it allows me to enter only phone numbers and I receive a notification.

    This is what is not working for me:

    when I type the first 3 numbers, it is fine, as soon as the symbol (-) gets populated by itself its telling me to enter numbers only.

    1 - How do I fix this code in order to let me enter numbers only and I don't receive a notification when the symbol (-) gets populated automatically

    I attached a sample document .

    Thank you
    Attached Files Attached Files

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Formatting Textbox to type phone numbers only

    Try this:-
    This code should only let you enter numbers in Your Format.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-02-2013
    Location
    Miami
    MS-Off Ver
    Excel 2010
    Posts
    89

    Re: Formatting Textbox to type phone numbers only

    Thank you MickG

    1 - How can I fix the code in order for the symbol (-) to appears automatically, basically I would like to type the first 3 numbers and then the (-) will be put automatically and so on, as in my attachment.

    2 - how can I make the length of the information that will be written in the textbox to 12 characters only.

    Regards,

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Formatting Textbox to type phone numbers only

    Change lines below:-
    Please Login or Register  to view this content.
    Last edited by MickG; 11-26-2015 at 02:04 PM.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Formatting Textbox to type phone numbers only

    You could use code like this.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Registered User
    Join Date
    12-02-2013
    Location
    Miami
    MS-Off Ver
    Excel 2010
    Posts
    89

    Re: Formatting Textbox to type phone numbers only

    Thank you guys

    Mike – I tried changing it but it’s not working, would you mind trying on my document and let me know please.

    Mikerickson – I tried putting all of them and nothing happened, could you please use it on my document and please let me know if I’m doing something wrong?


    Sorry guys that I’m not a VBA expert

    Thank you

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Formatting Textbox to type phone numbers only

    Hi eddyrcabrera79

    Place this Code in a Standard Module (Module1 in the attached)
    Please Login or Register  to view this content.
    In the DinnerPlannerUserForm Module add this Code
    Please Login or Register  to view this content.
    In the DinnerPlannerUserForm Module replace PhoneTextBox_Change() with this
    Please Login or Register  to view this content.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  8. #8
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Formatting Textbox to type phone numbers only

    Remove "PhoneTextBox_Change()" Code and replace with below:-

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    12-02-2013
    Location
    Miami
    MS-Off Ver
    Excel 2010
    Posts
    89

    Re: Formatting Textbox to type phone numbers only

    Thank you so much Jaslake and MickG. Both work. thank you so much for the awesome help

  10. #10
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Formatting Textbox to type phone numbers only

    You're welcome

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Formatting Textbox to type phone numbers only

    You're welcome...glad I could help.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ 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] Formatting Phone and Celular Numbers
    By Andrei Kononenko in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-08-2012, 08:14 AM
  2. Formatting phone numbers
    By contaminated in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-23-2011, 04:10 PM
  3. Excel 2007 : Formatting Phone numbers
    By Dena Marie in forum Excel General
    Replies: 1
    Last Post: 09-23-2009, 02:53 PM
  4. Formatting Phone Numbers
    By geezee in forum Excel General
    Replies: 1
    Last Post: 07-24-2009, 12:49 PM
  5. Formatting Phone numbers
    By wlthplan in forum Excel General
    Replies: 3
    Last Post: 03-22-2007, 11:33 AM
  6. [SOLVED] When merging phone numbers do not keep formatting why?
    By Excel formatting troubles in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-14-2006, 06:35 PM
  7. When merging phone numbers do not keep formatting why?
    By Excel formatting troubles in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-14-2006, 03:55 PM
  8. Formatting Phone Numbers
    By Tha BeatMaker in forum Excel General
    Replies: 7
    Last Post: 07-02-2005, 05:43 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