+ Reply to Thread
Results 1 to 4 of 4

Excel cell data validation

  1. #1
    Registered User
    Join Date
    11-19-2012
    Location
    Tamil Nadu,India
    MS-Off Ver
    Excel 2007
    Posts
    1

    Excel cell data validation

    In my excel form, C column is US-Phone No. If user enters other than below format it has to show Error Message "Invalid phone no".

    Formats are,

    Correct

    212.123.1234
    212 123 1234
    212-123-1234
    (212)123-1234

    InCorrect

    2122.123.1234
    212 123 1234aa
    aaa-aaa-aaaa etc...



    Last edited by hari_infotech; 11-19-2012 at 09:46 AM.

  2. #2
    Registered User
    Join Date
    01-21-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Excel cell data validation

    That means that data validation works

    Somebody wanted to have numbers in these formats. Try to erase data validation from that cells.

  3. #3
    Forum Contributor dogberry's Avatar
    Join Date
    07-15-2012
    Location
    Wales, UK
    MS-Off Ver
    Excel 2010
    Posts
    624

    Re: Excel cell data validation

    Hi

    You could of course amend the data validation message from Invalid Phone no to a message that actually shows the correct format.

    Chris
    Click my star if I helped Thanks

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Excel cell data validation

    You could test the values with a small User Defined Function:

    Please Login or Register  to view this content.
    So if C3 contains phone number, in another column:
    =GoodPhone(C3)
    would display the error message, otherwise a blank.


    User Defined Functions (UDFs) are very easy to install and use:

    1. ALT-F11 brings up the VBE window
    2. ALT-I
    ALT-M opens a fresh module
    3. paste the stuff in and close the VBE window

    If you save the workbook, the UDF will be saved with it.

    To remove the UDF:
    1. bring up the VBE window as above
    2. clear the code out
    3. close the VBE window
    To use the UDF from Excel:

    =GoodPhone(C1)

    To learn more about macros in general, see:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    or

    http://www.cpearson.com/excel/Writin...ionsInVBA.aspx

    for specifics on UDFs

    Macros must be enabled for this to work!
    Last edited by Jakobshavn; 11-19-2012 at 10:08 AM.
    Gary's Student

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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