Excel complex lookup

Dear Experts,

I am trying to strip out the countries contained in an address field and return a "country code" value in the next column, the formula would read "If Cell A2 contains any string value from Sheet2 A:A then return the corresponding value from Sheet2 B:B"

Country codes look like this:
Country     Code
Poland         EU-POLAND
Portugal         EU-PORT
Romania         EU-ROMANIA
Russia         EU-RUSSIA
Spain         EU-SPAIN
Sweden         EU-SWEDEN

so if Cell A2 had the word Romania in it then it would return the value "EU-ROMANIA"

Can anybody help
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saurabh Singh TeotiaCommented:
You can use this formula and drag it..

B2 formula is..

="EU-" & a2

correlateAuthor Commented:
Sorry I think I explained this badly, the table in the example is purely the lookup / results.  The data I an looking to run the formula across is a full address, so something like this:

flat12, London Road, Warsaw, Poland, PL123-345.

because that cell contains the word "Poland" it would return the code "EU-POLAND"
Saurabh Singh TeotiaCommented:

Can you give me your sample file about how does your data looks like and i can help you write the logic for lookup...

Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

correlateAuthor Commented:
Hi Saurabh,

Sorry for the delay - I was stuck on a call - attached is an example

Many thanks
Saurabh Singh TeotiaCommented:
I'm assuming this is what you are looking for..


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

in E2, pls try

=VLOOKUP(TRIM(MID(SUBSTITUTE($D2,",",REPT(" ",999)),(COLUMNS($A:D)*999)-998,999)),'Country Codes'!$A$2:$B$22,2,FALSE)

Open in new window

correlateAuthor Commented:
both work brilliantly - many thanks for your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.