Text Function Formulas - Find/Substitute/Replace

CleverUserName

New Member
Joined
Nov 25, 2018
Messages
11
Hello,
I have Street Names in Column A. They are all different and may contain apartment or unit numbers at the end.

I would like to search the text in the cell from RIGHT to LEFT to find the first instance of "ST" or "AVE" or "RD". I would then like to remove any text to the right from that point in the cell leaving everything to left including my search string. I would also like to account for error handling in case the search string is not found.

Thank you.


Street NameDesired Result
STANLEY ST.UNIT 2ASTANLEY ST
ALDINE ST 3BALDINE ST
S 18TH STS 18TH ST
AVELINE AVE APT N-3AVELINE AVE
SMITH RD. 24GSMITH RD

<tbody>
</tbody>
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi,

It looks like you can also search from left to right if we include a space, i.e. search for " ST", " AVE" and " RD".

=LEFT(A2,LOOKUP(2^15,SEARCH(" "&{"AVE","RD","ST"},A2)+{3,2,2}))

Regards
 
Upvote 0
Apologies - forgot you wanted error-handling. What do you want it to return in such cases?

This version will return the original string if none of "AVE", "RD", "ST" are found:

=LEFT(A2,LOOKUP(2^15,SEARCH({""," AVE"," RD"," ST"},A2)+{1000,3,2,2}))

Regards
 
Upvote 0

Forum statistics

Threads
1,214,412
Messages
6,119,369
Members
448,888
Latest member
Arle8907

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