How to automatically trim a comma off? So I don't have to remove it manually?
How to remove comma from end of Google Sheets cell if it ends with a comma?
what does ,$ mean? –
Messiah
it means: "remove comma if a comma is at the far end" –
Sherlocke
not rly sure what you asking about...
REGEXREPLACE
is like a SUBSTITUTE
formula, but more flexible. SUBSTITUTE
can work with only what is present in cell while REGEXREPLACE
can work with additional parameters like $
in this case which can be translated as "from end" (^
would be "from begining" so if you would had cell like ,a, b,
then you could do =REGEXREPLACE(A1, "^,|,$", ))
where |
means "and") –
Sherlocke =IF(RIGHT(B2,1)=",",LEFT(B2,LEN(B2)-1),B2)
Using IF
and LEN
.
If the last character of a cell value is a comma, then the answer should be the length of the cell minus the last character (the comma)
If the last character is not a comma, just pass the original value.
© 2022 - 2024 — McMap. All rights reserved.