Closed Thread
Results 1 to 18 of 18

Postcode validation

  1. #1
    Registered User
    Join Date
    10-06-2011
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2010
    Posts
    6

    Postcode validation

    Postcode format

    L - Letter N - Number

    LLNN NLL
    and
    LLN NLL

    Does anyone know what validation/formula I need to use, so that users can only enter a postcode in the same format as the 2 variations above?

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,758

    Re: Postcode validation

    Are you sure those are the only formats you need - there are other possibilities for UK postcodes....
    Audere est facere

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Postcode validation

    This is some event code that I use

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-06-2011
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Postcode validation

    thanks.

    Is it possible to use a formula or is using code the only way i will be able to include validation?

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Postcode validation

    Testing for patterns like those can get quite complex using data validation formulas.. that is one reason why VBA might be better, and also it is a reason why you were asked if those are the only 2 patterns necessary to validate.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  6. #6
    Registered User
    Join Date
    10-06-2011
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Postcode validation

    thanks.

    Is it possible to use a formula or is using code the only way i will be able to include validation?

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Postcode validation

    You said that already.

  8. #8
    Registered User
    Join Date
    10-06-2011
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Postcode validation

    those are the 2 most common patterns that will be entered, but if it's possible to include other variations in the validation then i would like to do that.

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Postcode validation

    Hi,

    Bob's code does that, can't you use this.

    @Bob, there's also another one - "[A-Z][A-Z]#[A-Z] #[A-Z][A-Z]"

  10. #10
    Registered User
    Join Date
    10-06-2011
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Postcode validation

    ok thanks, I'll try it and see.

  11. #11
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Postcode validation

    Quote Originally Posted by Kyle123 View Post
    Hi,

    Bob's code does that, can't you use this.

    @Bob, there's also another one - "[A-Z][A-Z]#[A-Z] #[A-Z][A-Z]"
    Where is that one Kyle?

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,758

    Re: Postcode validation

    The postcode for New Scotland Yard is in that format - SW1H 0BG

    There are other London postcodes of that type too WC1H.....etc.

  13. #13
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Question Re: Postcode validation

    Quote Originally Posted by daddylonglegs View Post
    The postcode for New Scotland Yard is in that format - SW1H 0BG

    There are other London postcodes of that type too WC1H.....etc.
    I get a feeling I have been round this loop before

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Postcode validation

    You guys on that side are confusing...

    ours (Canada) is just one..

    [A-Z]#[A-Z] #[A-Z]#

  15. #15
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,758

    Re: Postcode validation

    .......the GIRO postcode also breaks the rules - GIR 0AA

    I think this is up to date. It gives you more detailed information such as which letters can appear in which positions

  16. #16
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Postcode validation

    Good Link DLL

    I only know because something I did broke when someone used a London postcode and everything came crashing down...(well people whining anyway!! )

  17. #17
    Registered User
    Join Date
    07-27-2021
    Location
    England
    MS-Off Ver
    mAC 16.47.1
    Posts
    2

    Re: Postcode validation

    Hi,

    I have this working perfectly in one column however i have 2 columns with 2 different postcodes, how can i get this formula to work on 2 separate columns?

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,327

    Re: Postcode validation

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

Closed 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