Replace multiple text within a single cell

Country_Calc

New Member
Joined
Feb 14, 2017
Messages
48
Office Version
  1. 365
I need to change 2 letter country codes to the full country name, but have many countries within a single cell.

Table below shows the desired output. But it could have 30 country codes in a single cell.

AB
AD, AOAndorra, Angola
AO, AIAngola, Aguilla


It would be nice to use a formula to reference a table that has all of these, but I could also do manually if needed. Example of list is below.

2 letter code​
Country​
AD​
Andorra​
AO​
Angola​
AI​
Anguilla​
 
The reference to another worksheet works now and would probably be ideal for users having similar issues. There is 1 minor issue in that if the cell only has 1 value ex. "CA" it returns a #CALC error. But since this only affects cells with a single value it is a very quick manual fix from there.
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
If you have only one code, you can use
Excel Formula:
=LET(f,FILTERXML("<k><m>"&SUBSTITUTE(A2,", ","</m><m>")&"</m></k>","//m"),r,ROWS(f),a,FILTER(Countries,ISNUMBER(MATCH(INDEX(Countries,,1),f,0))),IF(r=1, INDEX(INDEX(Countries,,2),MATCH(A2,INDEX(Countries,,1),0)),TEXTJOIN(", ",,INDEX(SORTBY(a,MATCH(INDEX(a,,1),f,0)),,2))))
 
Upvote 0

Forum statistics

Threads
1,215,596
Messages
6,125,726
Members
449,255
Latest member
whatdoido

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