Solved

IF Statement

Posted on 2016-11-11
3
44 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

623 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