Formula for pulling State from Cell

Craig92604

Well-known Member
Joined
Nov 7, 2002
Messages
505
I put together this formula to pull the state from a cell that contains City, State and Zip

=MID(B19,FIND(" ",B19,1),3)

Works fine for when the City is One word but when it is two words it doesn't work.

This formula works if there is two word city=MID(B19,FIND(" ",B19,FIND(" ",B19,C19+1)),3)

What I am looking for is a formula to count the number of spaces in a cell. Then I could build a nested if statment to handle cells with both 1 and two word cities.

PS- There is not a comma after the city
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
=LEN(B19)-LEN(SUBSTITUTE(B19," ","")) will tell you how many spaces in B19
 
Upvote 0
Worked Like a Charm! Thanks Andrew and NBVC!

=IF(LEN(B19)-LEN(SUBSTITUTE(B19," ",""))>2,MID(B19,FIND(" ",B19,FIND(" ",B19,FIND(" ",B19,1)+1)),3),MID(B19,FIND(" ",B19,1),3)
)
 
Upvote 0

Forum statistics

Threads
1,222,227
Messages
6,164,723
Members
451,912
Latest member
HMF009

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