Extract UK post code from a single column filled with addresses

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,922
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a column which contains UK addresses, collected from users via a website submission form.

As such, loads of input issues without any structure to the post code (lower case, 7 or 8 digits long, sometimes with a space in between, other times no post code provided at all), example of redacted data:

Book1
N
1Address
24 captain's field llanfrynach
3Maida Vale
4jgljglj
522 Osprey AVE. Westhoughton,Bolton by
65 north lodge Chester le street dh34ba
7gfbdxvzfxvcsdfvfdv
842 gawsworth close
9Padang
1016 Huntsmead
11jgljglj
1215 Main Street Ledston Wf102aa
13Chikamagalur
149285 solstivve
155 tanton road
16Maida Vale
17109 Rushton Grove Harlow Essex CM17 9QW
18165 knightsbridge
1912 Gough Square
2095 Midanbury Lane bitterne Southampton SO18 4HA
2176Jubilee way Rogerstone Newport NP10 9NL
22Flat4 2Sorrell street hulme machester M155SR
2332 Roman Road
24Flat4 2Sorrell street hulme machester M155SR
2593 Ruby Street
2616 the spinney
2753 Talbot Ave Kingswood Bristol BS15 1HE
2828 Avon Hockley TAMWORTH Staffordshire B77 5QA
2937A The Avenue, Stockton-on-Tees, TS19 7EP
3010 Mansell Rd Shoreham west sussex
31Rosemead, High St, Clotton, Tarporley, Cheshire, CW60EG
3255 abbeystead avenue L301pn
33Hazrich Ironworks Road, Tow Law, Bishop Auckland, Co. Durham DL13 4EQ
3419 Greenleigh Close Bolton BL17BQ
3519 Greenleigh Close Bolton BL17BQ
3619 Greenleigh Close Bolton BL17BQ
3716 Lucerne Way Harold Hill Rm3 8BS
38Woodlea
3925 Cheshire road Birmingham b6 7bx
4021 lonsdale avenue
41137 prince of wales road
4275 thornbarrow road windermere cumbria la232dq
43The Brae, Port William
4414 North Road, Alconbury Weston, Huntingdon, PE28 4JR
4517 nelson road wouldham kent
4638 doncaster vroad
Data


How can I extract the post code only? Formula or Power Query solutions preferrred.

TIA,
Jack
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Or VBA with RegEx (not sure of syntax), with patterns to try:

"%r{[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][A-Z]{2}}i"

"/^(([A-Z][A-Z]{0,1})([0-9][A-Z0-9]{0,1})) {0,}(([0-9])([A-Z]{2}))$/i"
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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