Split City/State From A String.

Cubist

Well-known Member
Joined
Oct 5, 2023
Messages
1,803
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi, I'm trying to split City/State from strings in column (A) into (B) & (C) like below. The state is always the last 2 letters before the numbers. The rest of it is the city.

String (A)City (B)State (C)
SPRINGFIELD MA 010SPRINGFIELDMA
CAPE COD MA 025CAPE CODMA
WHITE RIV JCT VT 035WHTIE RIV JCTVT
PORTSMOUTH NH 038PORTSMOUTHNH
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Are the number always exactly 3 digits long?

If so, for an entry in cell A2, put this in cell C2:
Excel Formula:
=LEFT(RIGHT(A2,6),2)
and this in cell B2:
Excel Formula:
=TEXTBEFORE(A2," " &C2&" ")
 
Upvote 0
Are the number always exactly 3 digits long?

If so, for an entry in cell A2, put this in cell C2:
Excel Formula:
=LEFT(RIGHT(A2,6),2)
and this in cell B2:
Excel Formula:
=TEXTBEFORE(A2," " &C2&" ")
Hi Joe,
Sorry for not catching this earlier but I've looked at the dataset again. There's another case where the last part has a U like this...

WHITE RIV JCT VT 035U

This is the source under column A.
 
Upvote 0
OK, if we change the formula in cell C2 slightly to this, it should work for both those cases:
Excel Formula:
=LEFT(TRIM(RIGHT(A2,7)),2)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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