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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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