Categorize from list base on list

freqzz

New Member
Joined
Nov 19, 2013
Messages
9
Hi everyone,

Sorry for the title, a bit confusion. Not sure if I cant articulate this well enough.

I would like to categorize a set of information based on a list. Let me show you what i mean.

This is the information I have.

City

HK
Hong Kong
New York
Jersey
New Jersey
Manila
Makati

If I group that together it will come back to 7 group.

Would like to simplify base on a list (or dictionary that can be add on) like this

ListGroup
HKHK
hon konHK
heh keeHK
UsUS
USAUS
americaUS
NYUS

<tbody>
</tbody>


So what im trying to do is for each city, look at the list and group them accordingly per group.

Is that possible?

Regards,
Freqzz
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
In my opinion, you need first have a mapping table for the cities and countries, like the one you show above.

Then use "VLOOKUP" function to identify the "Group" for each city, based on the mapping table.
 
Upvote 0
Yes, I was thinking about vlookup but the trick is, if the city contains other unrelated comments. Maybe I should have make it clear.. say if i have a field contain :

City
Trip to HK
Business ticket to hong kong
return from NY
New York visit

How do i manage those?
 
Upvote 0
One way I can think of is use macro to loop each city in your mapping table, search if the text contains the city name. If yes, identify the corresponding group in your mapping. If not, loop to the next city name in your mapping table.

You can use "instr" to check if the city name is within the text. If the returned value is larger than 0, the city name is in the text.
 
Upvote 0
Ok i found the solution but just one issue. If you open the spreadsheet, how do I change the formula to reflect supposed result which is in column C (which looksup to colum E)

A B C D E
PurposeFormula ResultSupposed ResultListGroup
HK tripHKHong KongHKHong Kong
Operation impovement hong kongHong KongHong KongHong KongHong Kong
Business related nyNYNew YorkNYNew York
N YorkN YorkNew YorkN YorkNew York

<tbody>
</tbody>

The formula i used is :

Code:
=INDEX($E$2:$E$6,MATCH(TRUE,INDEX(ISNUMBER(SEARCH($E$2:$E$6,A2)),),0))

Please help.

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,125,000
Members
449,202
Latest member
Pertotal

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