Removing the last comma from a cell - Formula Also Removes the Preceding Zero

Theemeadelis

New Member
Joined
Jul 10, 2023
Messages
20
Office Version
  1. 365
Platform
  1. Windows
I have a data set where I need to remove the last comma that is appearing in a lot of the cells. As there is often a space after the last comma too, I have been using the below formula:

=LEFT(A1,LEN(TRIM(A1))-(RIGHT(TRIM(A1))=","))

Unfortunately I have found that if a cell has a zero before the last comma, the above formula is also removing the zero as well - please see the below example:

1689497150375.png


Does anyone know why this is happening, and how I can get the formula to work without also removing the zero that precedes the last comma?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Nothing wrong with your formula. Works fine here.


Excel Formula:
=TEXTBEFORE(A1&"^",",^",,,,A1)
 
Upvote 0
Does anyone know why this is happening
From looking at you image I suspect it is because there is a double space after the ":"

and how I can get the formula to work without also removing the zero that precedes the last comma?
My TEXTBEFORE is marginally different

23 07 16.xlsm
HI
1
2APT: N030APT: N030
3APT: N090, N120,APT: N090, N120
4APT: N090, N120, APT: N090, N120
Last Comma
Cell Formulas
RangeFormula
I2:I4I2=TEXTBEFORE(H2,",",-1,,,H2)


@JEC
I think that you may have overlooked this:
there is often a space after the last comma too,
 
Upvote 1
Solution

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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