Solved

IF Statement

Posted on 2016-11-11
3
38 Views
Last Modified: 2016-11-11
I am new to writing excel statements and trying to filter out scottish postcodes from over 3500 records to give the value "Scotland" or England.  My statment is incorrect - can you please help?

=IF(L2="KS",Scotland”,L2="KA",”Scotland”,L2="TD",”Scotland”,L2="DG",”Scotland”,L2="EH",”Scotland”,L2="KY",”Scotland”,L2="FK",”Scotland”,L2="AB",”Scotland”,IF(L2="G",”Scotland”,IF(L2="PA",”Scotland”,IF(L2="IV",”Scotland”,IF(L2="ML",”Scotland”,IF(L2="EH",”Scotland,IF(L2="KW",”Scotland”,IF(L2="ZE",”Scotland”,IF(L2="DD",”Scotland”,IF(L2="PH","Scotland","England")))))))))))))))))
0
Comment
Question by:Gwynneth Taylor
3 Comments
 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 500 total points
ID: 41883618
It would be better to use a VLookup function. Create a list with 2 columns i.e. PostCode, Country. I suggest you put it in a table. Your function would then look something like:

=VLookup(L2, [YourTableName e.g Table1], 2, 0)

I also found this link which may be helpful. You can get all post codes there as a download:
https://www.doogal.co.uk/UKPostcodes.php

I also attach an example
vlookupExample.xlsx
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 41883650
A lookup table would be much easier to maintain but you could use the OR function instead:

=IF(OR(L2="KS",L2="KA",L2="TD",L2="DG",L2="EH",L2="KY",L2="FK",L2="AB",L2="G",L2="PA",L2="IV",L2="ML",L2="EH",L2="KW",L2="ZE",L2="DD",L2="PH"),"Scotland","England")

Does L2 contain the whole postcode or just the first characters?
0
 

Author Closing Comment

by:Gwynneth Taylor
ID: 41883655
Excellent quick response and problem solved thank you.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question