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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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