Reference UK Post Code Column to Create and print Country from a reference table? IF formula or VLookup?

brainache

New Member
Joined
Mar 1, 2007
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi Guys, hope everyone is well!? Been about 10 years since my last visit. Pleased to see the forum still going strong! Recently have been doing a bit of work with PowerBi (which is basically PowerPivot with a prettier face).

My excel skills and knowledge seem to have evaporated since having kids!

I think I am trying to achieve something simple, but your help is appreciated.
--

I have a dataset in excel containing thousands of rows of devices, there are multiple columns, but I'm interested in simplifying the location column from postcode to Country in the UK We have a column with a postcode of the device. I simply want to create an additional column and have the Country Name displayed.

I need to work a way out to construct a formula or vlookup to look only at the first 2 letters of the Post Code then print the country based on the below table. IS something like that possible or would it be a long and involved COUINTIF formula or as I have the below use vlookup? Any tips appreciated!

Example Dummy Dataset

1697724592260.png


Reference Table for Country



Postcode AreaPostcode Area NameRegionCountry
ABAberdeenScotlandScotland
ALSt. AlbansEast of EnglandEngland
BBirminghamWest MidlandsEngland
BABathSouth WestEngland
BBBlackburnNorth WestEngland
BDBradfordNorth WestEngland
BHBournemouthSouth WestEngland
BLBoltonNorth WestEngland
BNBrightonSouth EastEngland
BRBromleyGreater LondonEngland
BSBristolSouth WestEngland
BTBelfastNorthern IrelandIreland
CACarlisleNorth WestEngland
CBCambridgeEast of EnglandEngland
CFCardiffWalesWales
CHChesterNorth WestEngland
CMChelmsfordEast of EnglandEngland
COColchesterEast of EnglandEngland
CRCroydonGreater LondonEngland
CTCanterburySouth EastEngland
CVCoventryWest MidlandsEngland
CWCreweNorth WestEngland
DADartfordGreater LondonEngland
DDDundeeScotlandScotland
DEDerbyEast MidlandsEngland
DGDumfriesScotlandScotland
DHDurhamNorth EastEngland
DLDarlingtonNorth EastEngland
DNDoncasterEast MidlandsEngland
DTDorchesterSouth WestEngland
DYDudleyWest MidlandsEngland
ELondonGreater LondonEngland
ECLondonGreater LondonEngland
EHEdinburghScotlandScotland
ENEnfieldGreater LondonEngland
EXExeterSouth WestEngland
FKFalkirkScotlandScotland
FYBlackpoolNorth WestEngland
GGlasgowScotlandScotland
GLGloucesterSouth WestEngland
GUGuilfordSouth EastEngland
GYGuernseyChannel IslandsChannel Isles
HAHarrowGreater LondonEngland
HDHuddersfieldNorth WestEngland
HGHarrogateNorth EastEngland
HPHemelEast of EnglandEngland
HRHerefordWest MidlandsEngland
HSComhairle nan Eilean SiarScotlandScotland
HUHullNorth EastEngland
HXHalifaxNorth WestEngland
IGIlfordGreater LondonEngland
IMIsle of ManIsle of ManIsle of Man
IPIpswichEast of EnglandEngland
IVInvernessScotlandScotland
JEJerseyChannel IslandsChannel Islands
KAKilmarnockScotlandScotland
KTKingstonGreater LondonEngland
KWKirkwallScotlandScotland
KYKirkaldyScotlandScotland
LLiverpoolNorth WestEngland
LALancasterNorth WestEngland
LDLlandrindodWalesWales
LELeicesterEast MidlandsEngland
LLLlandudnoWalesWales
LNLincolnEast MidlandsEngland
LSLeedsNorth EastEngland
LULutonEast of EnglandEngland
MManchesterNorth WestEngland
MEMedwaySouth EastEngland
MKMilton KeynesSouth EastEngland
MLMotherwellScotlandScotland
NLondonGreater LondonEngland
NENewcastleNorth EastEngland
NGNottinghamEast MidlandsEngland
NNNorthamptonWest MidlandsEngland
NPNewportWalesWales
NRNorwichEast of EnglandEngland
NWLondonGreater LondonEngland
OLOldhamNorth WestEngland
OXOxfordSouth EastEngland
PAPaisleyScotlandScotland
PEPeterboroughEast EnglandEngland
PHPerthScotlandScotland
PLPlymouthSouth WestEngland
POPortsmouthSouth EastEngland
PRPrestonNorth WestEngland
QCAwarding BodiesNon-geographic
RGReadingSouth EastEngland
RHRedhillSouth EastEngland
RMRomfordGreater LondonEngland
SSheffieldEast MidlandsEngland
SASwanseaWalesWales
SELondonGreater LondonEngland
SGStevenageEast of EnglandEngland
SKStockportNorth WestEngland
SLSloughSouth EastEngland
SMSuttonGreater LondonEngland
SNSwindonSouth WestEngland
SOSouthamptonSouth EastEngland
SPSalisburySouth WestEngland
SRSunderlandNorth EastEngland
SSSouthendEast of EnglandEngland
STStoke on TrentWest MidlandsEngland
SWLondonGreater LondonEngland
SYShrewsburyWalesWales
TATauntonSouth WestEngland
TDGalashielsScotlandScotland
TFTelfordWest MidlandsEngland
TNTonbridgeSouth EastEngland
TQTorquaySouth WestEngland
TRTruroSouth WestEngland
TSClevelandNorth EastEngland
TWTwickenhamGreater LondonEngland
UBSouthallGreater LondonEngland
WLondonGreater LondonEngland
WAWarringtonNorth WestEngland
WCLondonGreater LondonEngland
WDWatfordGreater LondonEngland
WFWakefieldNorth EastEngland
WNWiganNorth WestEngland
WRWorcesterWest MidlandsEngland
WSWalsallWest MidlandsEngland
WVWolverhamptonWest MidlandsEngland
YOYorkNorth EastEngland
ZEShetlandScotlandScotland
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 1
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Apologises - I have updated this. I also have access to O365 E5 features if needed.
 
Upvote 0
Thanks for that. (y)
How about
Fluff.xlsm
DEFGHIJKLMNOP
1Postcode AreaPostcode Area NameRegionCountry
2OL13 8FDEnglandABAberdeenScotlandScotland
3BD13 3NREnglandALSt. AlbansEast of EnglandEngland
4DD3 1RGScotlandBBirminghamWest MidlandsEngland
5CF11 6JDWalesBABathSouth WestEngland
6EH23 6DEScotlandBBBlackburnNorth WestEngland
7BT20 9NUIrelandBDBradfordNorth WestEngland
8LS29 0EHEnglandBHBournemouthSouth WestEngland
9DH7 9QWEnglandBLBoltonNorth WestEngland
sheet6
Cell Formulas
RangeFormula
E2:E9E2=XLOOKUP(TEXTBEFORE(D2,SEQUENCE(10,,0)),$M$2:$M$126,$P$2:$P$126)
 
Upvote 0
Thanks for that. (y)
How about
Fluff.xlsm
DEFGHIJKLMNOP
1Postcode AreaPostcode Area NameRegionCountry
2OL13 8FDEnglandABAberdeenScotlandScotland
3BD13 3NREnglandALSt. AlbansEast of EnglandEngland
4DD3 1RGScotlandBBirminghamWest MidlandsEngland
5CF11 6JDWalesBABathSouth WestEngland
6EH23 6DEScotlandBBBlackburnNorth WestEngland
7BT20 9NUIrelandBDBradfordNorth WestEngland
8LS29 0EHEnglandBHBournemouthSouth WestEngland
9DH7 9QWEnglandBLBoltonNorth WestEngland
sheet6
Cell Formulas
RangeFormula
E2:E9E2=XLOOKUP(TEXTBEFORE(D2,SEQUENCE(10,,0)),$M$2:$M$126,$P$2:$P$126)
Wow, Thank You for the quick reply! I shall give it a play tonight!! Awesome!
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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