Replacing multiple text within same cell

Country_Calc_2

New Member
Joined
Sep 16, 2023
Messages
27
Office Version
  1. 365
Platform
  1. Windows
I need to replace multiple text values within a single cell as shown below. In this case the separator is a semicolon.. The replacement values would be in a separate list with example below.

Any help would be greatly appreciated.

BeforeAfter
United States;United Kingdom;France;Germany;Israel;Italy;SpainUSA, GBR, FRA, DEU, ISR, ITA, ESP


DefinitionCode Value
FranceFRA
GermanyDEU
IsraelISR
ItalyITA
SpainESP
United KingdomGBR
United StatesUSA
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
See if this works for you:
Book1
AB
1BeforeAfter
2United States;United Kingdom;France;Germany;Israel;Italy;SpainUSA, GBR, FRA, DEU, ISR, ITA, ESP
3
4
5DefinitionCode Value
6FranceFRA
7GermanyDEU
8IsraelISR
9ItalyITA
10SpainESP
11United KingdomGBR
12United StatesUSA
13
14
15United States;United Kingdom;France;Germany;Israel;Italy;SpainUSA,GBR,FRA,DEU,ISR,ITA,ESP
Sheet2
Cell Formulas
RangeFormula
B15B15=LET(FullNames,TEXTSPLIT(A15,";"),FullNameList,$A$6:$A$12,FullNameShort,$B$6:$B$12, Shorts,BYCOL(FullNames,LAMBDA(Fullnames,XLOOKUP(Fullnames,FullNameList,FullNameShort,"notfound",0,1))), TEXTJOIN(",",TRUE,Shorts))
 
Upvote 0
Solution
This does work thanks. I have to have my list on another worksheet so I used a named range using the same names. This is probably not ideal but it works. Thanks again.

=LET(FullNames,TEXTSPLIT(Y4,";"),FullNameList,FullNameList,FullNameShort,FullNameShort,
Shorts,BYCOL(FullNames,LAMBDA(Fullnames,XLOOKUP(Fullnames,FullNameList,FullNameShort,"notfound",0,1))),
TEXTJOIN(", ",TRUE,Shorts))
 
Upvote 0
Does the problem need such a complicated formula? Wouldn't this be sufficient?

24 03 02.xlsm
AB
5DefinitionCode Value
6FranceFRA
7GermanyDEU
8IsraelISR
9ItalyITA
10SpainESP
11United KingdomGBR
12United StatesUSA
13
14
15United States;United Kingdom;France;Germany;Israel;Italy;SpainUSA,GBR,FRA,DEU,ISR,ITA,ESP
Abbreviations
Cell Formulas
RangeFormula
B15B15=TEXTJOIN(",",,XLOOKUP(TEXTSPLIT(A15,";"),A6:A12,B6:B12))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

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