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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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
9062 Old Annapolis Rd, COLUMBIA9062 Old Annapolis Rd
50 Main St, 5th floor, WHITE PLAINS50 Main St, 5th floor
123 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>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]

[TD="align: center"]3[/TD]

</tbody>
Sheet489

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B1[/TH]
[TD="align: left"]=TRIM(LEFT(SUBSTITUTE(A1,",",REPT(" ",99),LEN(A1)-LEN(SUBSTITUTE(A1,",",""))),99))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]


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,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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