• UK Postcode Format Check

    • This topic has 7 replies, 4 voices, and was last updated 24 years ago.
    Author
    Topic
    #356384

    Hello

    I need to validate, in VBA, whether or not a string matches the format pattern of a UK postcode – not whether the postcode exists or not, just whether it has a valid format.

    Does anyone have a snippet of VBA code which will do this that they could share with me?

    Thanks

    Paul grovel

    Viewing 2 reply threads
    Author
    Replies
    • #527327

      I am trying to find this out too (I have contacted the Royal Mail and am waiting for a reply). Thought someone else might have already been down this path before……..

      Paul shrug

      • #527333

        When I was working with international mailings, I gave up on even trying to validate a postal code pattern. I just upper cased everything and left it at that. If the mail service ever gives you a consistent pattern, post it and someone can help you with the code if need be.

        • #527334

          Thanks Charlotte, will do.

          Paul sigh

        • #527342

          Hi, I found this on the net for the UK postcode format:

          L(L)(N)(L) NLL

          where

          L = Letter
          N = Number
          () may or may not be there in correct postcodes

          I think ignoring/stripping the space would be a good start, but I don’t see that the like operator is flexible enough to handle this anyway?

          Any ideas?

          Paul help

          • #527366

            I think that you should leave the space in. The bit before the space is know as an region. As an example, take my work post code KT17 4RS

            The KT represents an district – Kingston Themes.
            The KT17 represents a region.
            The KT17 4 represents an area.

            Clear? No not very but that is the british way for you.

            Cheers,

            Tim

    • #527620
    • #527801

      Just come back after a long weekend.

      Thanks for all your help everyone!

      Paul cheers

    Viewing 2 reply threads
    Reply To: UK Postcode Format Check

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: