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.


[TABLE="width: 370"]
<tbody>[TR]
[TD]Street Name[/TD]
[TD]Desired Result[/TD]
[/TR]
[TR]
[TD]STANLEY ST.UNIT 2A[/TD]
[TD]STANLEY ST[/TD]
[/TR]
[TR]
[TD]ALDINE ST 3B[/TD]
[TD]ALDINE ST[/TD]
[/TR]
[TR]
[TD]S 18TH ST[/TD]
[TD]S 18TH ST[/TD]
[/TR]
[TR]
[TD]AVELINE AVE APT N-3[/TD]
[TD]AVELINE AVE[/TD]
[/TR]
[TR]
[TD]SMITH RD. 24G[/TD]
[TD]SMITH RD[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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,223,992
Messages
6,175,822
Members
452,672
Latest member
missbanana

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