+ Reply to Thread
Results 1 to 8 of 8

custom data validation formula to permit entry 5 digit numeric characters only

  1. #1
    Forum Contributor
    Join Date
    08-21-2008
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Office 2007
    Posts
    255

    custom data validation formula to permit entry 5 digit numeric characters only

    i require a formula for custom data validation to permit entry 5 digit numeric characters only.
    No spaces, or alpha permitted.
    Note that the cell format will be text, to enable leading zeros to be entered & displayed (as permitted)
    Thanks.

    refer previous post for similar for aplha only.
    http://www.excelforum.com/excel-work...ml#post2007297
    I was unable to adapt for my new requirement.

    Any help would be appreciated

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: custom data validation formula to permit entry 5 digit numeric characters only

    Hi,

    this is not Excel Programming, i.e. VBA, it should not be in the programming forum. But to answer your question:

    use the custom validation formula

    =AND(LEN(A1)=5,VALUE(A1)>0)

    which checks if the text string is 5 characters and also checks if the value of the text string interpreted as a number would be greater than zero.

  3. #3
    Forum Contributor
    Join Date
    08-21-2008
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Office 2007
    Posts
    255

    Re: custom data validation formula to permit entry 5 digit numeric characters only

    This causes an error when entering the formula. I expect this is due to having the cell formatted as text.

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: custom data validation formula to permit entry 5 digit numeric characters only

    Hi,
    you must format the cells to be text. Then apply the data validation to the cells. The attached workbook has the yellow highlighted cells formatted as text and the data validation applied.

    hth
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    08-21-2008
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Office 2007
    Posts
    255

    Re: custom data validation formula to permit entry 5 digit numeric characters only

    I still have this issue with error when updating manually or via VBA.
    But not always.
    See error screenshots and sample file with vba.
    Any help as to cause of error would be appreciated.
    Attached Images Attached Images
    Attached Files Attached Files

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: custom data validation formula to permit entry 5 digit numeric characters only

    thats coz a1 is empty just click ok and if a1 formated as text it will work
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  7. #7
    Forum Contributor
    Join Date
    08-21-2008
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Office 2007
    Posts
    255

    Re: custom data validation formula to permit entry 5 digit numeric characters only

    thanks for your reply.

    How can i prevent vba error if cell is empty.
    Other than if blank, insert a value, add validation, then clear cell value.

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: custom data validation formula to permit entry 5 digit numeric characters only

    try the programming forum!!!!!!

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