Quick Help with Excel

scott4lud

New Member
Joined
Jan 25, 2011
Messages
45
What formula would i use to just show the "MA" if below is in cell A1?


Worchester, MA 01602
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
T. Valko,

Can you explain how your formula works?
=TRIM(LEFT(RIGHT(SUBSTITUTE(A1," ",REPT(" ",100)),200),100))

A1 =
Worchester, MA 01602

Basically, we pad the spaces around "MA" then we use the RIGHT and LEFT functions to "narrow down" the string and finally we TRIM off the excess spaces that are left over.

For the purposes of this explanation I'll use smaller numbers to replace 100, 200 and 100. I'll use 10 and 20.

SUBSTITUTE(A1," ",REPT(" ",10)) =
"Worchester, MA 01602"

So we've padded a bunch of spaces around "MA".

RIGHT("Worchester, MA 01602",20) =
" MA 01602"

So we've "narrowed down" the string.

LEFT(" MA 01602",10) =
" MA "

So we've "narrowed down" the string even further.

TRIM(" MA ") =
MA

So we've used TRIM to remove all the excess spaces that were left.

Hopefully when I hit the Submit Reply button the forum software doesn't strip out all those space characters!
 
Upvote 0
=TRIM(LEFT(RIGHT(SUBSTITUTE(A1," ",REPT(" ",100)),200),100))

A1 =
Worchester, MA 01602

Basically, we pad the spaces around "MA" then we use the RIGHT and LEFT functions to "narrow down" the string and finally we TRIM off the excess spaces that are left over.

For the purposes of this explanation I'll use smaller numbers to replace 100, 200 and 100. I'll use 10 and 20.

SUBSTITUTE(A1," ",REPT(" ",10)) =
"Worchester, MA 01602"

So we've padded a bunch of spaces around "MA".

RIGHT("Worchester, MA 01602",20) =
" MA 01602"

So we've "narrowed down" the string.

LEFT(" MA 01602",10) =
" MA "

So we've "narrowed down" the string even further.

TRIM(" MA ") =
MA

So we've used TRIM to remove all the excess spaces that were left.

Hopefully when I hit the Submit Reply button the forum software doesn't strip out all those space characters!
OK, let's start over! :mad:

Imagine the underscores _ are spaces.

A1 =
Worchester,_MA_01602

Basically, we pad the spaces around "MA" then we use the RIGHT and LEFT functions to "narrow down" the string and finally we TRIM off the excess spaces that are left over.

For the purposes of this explanation I'll use smaller numbers to replace 100, 200 and 100. I'll use 10 and 20.

SUBSTITUTE(A1,"_",REPT("_",10)) =
Worchester,__________MA__________01602

So we've padded a bunch of spaces around "MA".

RIGHT("Worchester,__________MA__________01602",20) =
___MA__________01602

So we've "narrowed down" the string.

LEFT("___MA__________01602",10) =
___MA_____

So we've "narrowed down" the string even further.

TRIM("___MA_____") =
MA

So we've used TRIM to remove all the excess spaces that were left.
 
Upvote 0
T. Valko,

Thank you soooooooooo much.

This goes into my archives.

This has a lot of potential.
 
Upvote 0
What formula would i use to just show the "MA" if below is in cell A1?


Worchester, MA 01602
Sometimes we can't see the forest because of the trees!

If the cell entry is always in the same format:

[City][comma][single space][2 letter state abbreviation][single space][5 digit zip code]

Then:

=MID(A1,FIND(",",A1)+2,2)

The other formula I suggested is a generic formula that extracts the next to last word in a string which just happens to also work in this application.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,720
Members
448,986
Latest member
andreguerra

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