Delete text from right to left until Comma

MoreGone

New Member
Joined
Aug 15, 2016
Messages
14
Hello,

I am trying to format some addresses. They are currently "Street Address, CITY" and I am trying to remove the City along with the Comma.
Example: 9062 Old Annapolis Rd, COLUMBIA Want: 9062 Old Annapolis Rd

I have tried flash fill and while that mostly worked it went wonky on many of the entries. In a variety of ways.

I would use LEFT or RIGHT formulas with FIND but there are often more than one Comma in the address so I don't know how to make that work.
Example: 50 Main St, 5th floor, WHITE PLAINS

Any tips how to delete the City name and the Comma would be appreciated.

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi,

Assuming your addresses would not be longer than 99 characters:


Book1
AB
19062 Old Annapolis Rd, COLUMBIA9062 Old Annapolis Rd
250 Main St, 5th floor, WHITE PLAINS50 Main St, 5th floor
3123 E Ave., 2nd floor, Apt.B, Small Town123 E Ave., 2nd floor, Apt.B
Sheet489
Cell Formulas
RangeFormula
B1=TRIM(LEFT(SUBSTITUTE(A1,",",REPT(" ",99),LEN(A1)-LEN(SUBSTITUTE(A1,",",""))),99))
 
Last edited:
Upvote 0
Hi,

Assuming your addresses would not be longer than 99 characters:

AB
19062 Old Annapolis Rd, COLUMBIA9062 Old Annapolis Rd
250 Main St, 5th floor, WHITE PLAINS50 Main St, 5th floor
3123 E Ave., 2nd floor, Apt.B, Small Town123 E Ave., 2nd floor, Apt.B

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet489

Worksheet Formulas
CellFormula
B1=TRIM(LEFT(SUBSTITUTE(A1,",",REPT(" ",99),LEN(A1)-LEN(SUBSTITUTE(A1,",",""))),99))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>


That worked beautifully. Thank you! I will google to try and fully understand what is going on, but your brain is awesome. Thank you!
 
Upvote 0
You're very welcome, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,976
Members
449,095
Latest member
Mr Hughes

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