Validation of UK Postcodes all formats

Engineerlee

New Member
Joined
Nov 30, 2012
Messages
26
Hi
I am looking to validate UK postcodes in a similar fashion to another thread on here but it is quite old so thought I would generate a new one. Hopefully this isnt against the rules
UK Postal Code Validation

Hi, I am looking to validate UK Postal Code using MS Excel formula, can anyone help!!! The postal code is should be in the following format: AN NAA ANN NAA AAN NAA ANA NAA AANA NAA AANN NAA When A is alphabet and N is number. If the condition is incorrect then highlight that particular cell...

Can some one help
I am looking to do the same sort of validation including the CIKMOV check and illegal characters but with more postcode formats


My postcode field is always 9 characters in length
There are no spaces between the segments of the postcode - this would be considered incorrect and should report as such

Where a Postcode isnt the full 9 characters it is padded with spaces - these need to be also validated

AN[Space][Space][Space][Space][Space][Space][Space]
ANN[Space][Space][Space][Space][Space][Space]
AANA[Space][Space][Space][Space][Space]
ANNAA[Space][Space][Space][Space]
ANNNAA[Space][Space][Space]
AANNAA[Space][Space][Space]
ANANAA[Space][Space][Space]
AANANAA[Space][Space]
AANNNAA[Space][Space]
ANNAANA[Space][Space]
ANNNAANA[Space]
AANNAANA[Space]
ANANAANA[Space]
AANANAANA
AANNNAANA

Where A is alphabet character and N is number. [Space] is a physical space and not a word
If the condition is incorrect then highlight that particular cell that contains the incorrect postcode.
Many thanks in advance.
In reality they would look something like this

S1
S11
EC1A
S12BB
S112BB
LS12BB
W1A1BB
EC1A2BB
LS112BB
S12BB9Z
S112BB9Z
LS12BB9Z
W1A1BB9Z
EC1A2BB9Z
LS112BB9Z


Many thanks in advance
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Did you try the function, it looks valid to me
 
Upvote 0
Hi Mole999

thanks for your prompt reply
No I havent as it isnt a function I am familiar with

Could you give any examples at all as I need to be able to validate all of the combinations with any legal Postcode characters
From what I understand CODE only returns the ASCII for the first Character.

Cheers
 
Upvote 0
copy the provided function into the VBA section of the spreadsheet

The as instructed in an cell adjacent to the postcode type =the function name and cell reference as detailed, that will give you a response, you can drag that down the sheet
 
Upvote 0
Hi Mole999
Thanks for your return, and apologies as I didn't really understand your first post, however your second prompted me to look deeper at what I was looking to do.
you are right, I do get an output/response - which is great.. thankyou

There is one small issue........

It works with the exception of the last 2 examples
PostcodeChar CountOutput
S1
9​
TRUE​
S11
9​
TRUE​
EC1A
9​
TRUE​
S12BB
9​
TRUE​
S112BB
9​
TRUE​
LS12BB
9​
TRUE​
W1A1BB
9​
TRUE​
EC1A2BB
9​
TRUE​
LS112BB
9​
TRUE​
S12BB9Z
9​
TRUE​
S112BB9Z
9​
TRUE​
LS12BB9Z
9​
TRUE​
W1A1BB9Z
9​
TRUE​
EC1A2BB9Z
9​
#VALUE!​
DN112BB9Z
9​
#VALUE!​

If I add a space at the end then it returns a response, however the max characters allowed is 9 so these last 2 dont work unfortunately

is there a way to rectify this at all?
 
Upvote 0
You have me at 9 characters, I can't think of any occurances in the postal world, even with this reporting true S112BB9Z its not valid last three is number letter letter
 
Upvote 0
The last 2 characters are a delivery point code so the example you have highlighted is valid with the last (9Z) being the delivery point
Does that help explain?
 
Upvote 0
ah, OK, I only ever use the original part, so it could be safe to assume that if 9Z was eliminated and test against what is left
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top