Replace Last Space with Another Character

TheDave

New Member
Joined
Aug 3, 2011
Messages
11
In my cells I've got cities and states, with the one-word states being actually written out:

Aberdeen SD
North Platte Nebraska

I'd like to end up with a column of the cities and a column of the states. If I just do text to columns though, the cities with more than one word throw everything off. I can't just pull the last two characters over either, because some of the states are written out.

How can I replace the final space in the cell with, say, a semicolon? Then I can do text to columns and tell it to look for the semicolon divider, rather than the space.

I was originally trying to do something a little different if you want a greater challenge. I'd really prefer this:

Column A currently has something like:
Aberdeen South Dakota
New York New York
Fremont Nebraska

Again, I just want the state pulled over into the second column. So I'd love a formula that replaces the second to last space with a semicolon IF one of the two-word states is contained in that text (there are ten of those states--so Aberdeen South Dakota would become Aberdeen;South Dakota), or else it replaces the last space with a semicolon (so Fremont Nebraska would become Fremont;Nebraska).

I just figured it would be easier if I did a global find and replace on all the two-word states first because there are only ten of them, then pull the state into a second column. Since I haven't had much luck with that though, I'm open to the original plan if you can figure out a way to do it. Also, that would leave a couple cities abbreviated (like New York New York becomes NY NY), which isn't the end of the world, just not preferable either.

Thanks for your help.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,224,570
Messages
6,179,611
Members
452,931
Latest member
The Monk

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