Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

IF Statement

Posted on 2016-11-11
3
Medium Priority
?
49 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

722 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