Change list of states in a cell to their abbreviations

Doug Mutzig

Board Regular
Joined
Jan 1, 2019
Messages
57
Office Version
  1. 365
Platform
  1. Windows
Good morning all!

I just received an interesting request and I am not sure how to proceed. We have a table with one column that can hold 1 or more full state names separated by a semi-colon. What they would like is to have just the state abbreviations listed (see screenshot). Normally, I would use vlookup or index match in a new column to get the abbreviation but I don't know how to do this on multiple items within a cell. Is there a way to do this?
 

Attachments

  • Picture2.png
    Picture2.png
    23.6 KB · Views: 28

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Thank you for the info. I have updated with my version (365 - Windows).
 
Upvote 0
Quesion: Will you ever have the state of Mississippi to abbreviate? I ask because its abbreviation is MS which is the same as you show for Midsouth (which along with Midwest is not a state).
 
Upvote 0
Thanks for updating your profile.
Maybe
+Fluff 1.xlsm
ABCDEF
1
2California;Colorado;Midsouth;Midwest;Montana;CA;CO;MS;MW;MTCaliforniaCA
3Midsouth;MSColoradoCO
4MaineME
5MidsouthMS
6MidwestMW
7MontanaMT
Lists
Cell Formulas
RangeFormula
B2:B3B2=TEXTJOIN(";",,XLOOKUP(FILTERXML("<k><m>"&SUBSTITUTE(LEFT(A2,LEN(A2)-1),";","</m><m>")&"</m></k>","//m"),E2:E7,F2:F7,"",0))
 
Upvote 0
Solution
If the regions in the original list are in alphabetical order (like your samples) and Lookup table is also in alphabetical order (like your sample) then try the formula below.
If the values are not in the orders described above, the formula will still work but the abbreviations will come out in the order of the lookup table, not the order of the original data in column A - see row 7 for example. In any case this may not matter to you?

Doug Mutzig.xlsm
ABCDE
1
2California;Colorado;Iowa;CA;CO;IA;CaliforniaCA
3Midsouth;Oregon;MS;OR;ColoradoCO
4Maine;Midsouth;Ohio;ME;MS;OH;IndianaIN
5Midsouth;MS;IowaIA
6California;Midsouth;CA;MS;MaineME
7Maine;California;Ohio;Iowa;CA;IA;ME;OH;MidsouthMS
8MidwestMW
9MontanaMT
10OhioOH
11OregonOR
Sheet1
Cell Formulas
RangeFormula
B2:B7B2=TEXTJOIN(";",,FILTER(E$2:E$11,ISNUMBER(SEARCH(";"&D$2:D$11&";",";"&A2))))&";"
 
Upvote 0
Hi Flusff, and Peter_SSs. Than k you both for the great solutions. Fluffs solutions works great!

In answer to the question about Mississippi, currently we don't have plans for that to be listed, however, if it changes then I will need to update the list and probably break down the groups (midsouth and midwest) into their separate states.

Thank you again for the help on this!!!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,729
Messages
6,126,525
Members
449,316
Latest member
sravya

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