# How to remove a trailing comma from text in Excel

Drop the last character only when it is a comma: =IF(RIGHT(A2)=",",LEFT(A2,LEN(A2)-1),A2).

**Excel:** `=IF(RIGHT(A2)=",",LEFT(A2,LEN(A2)-1),A2)` (Microsoft 365 only)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| List (exported) | Clean |
| chair, desk, lamp, |  |
| monitor |  |
| dock, cable, |  |
| desk, lamp |  |
| mouse, |  |

Formula in B2, filled to B6: `=IF(RIGHT(A2)=",",LEFT(A2,LEN(A2)-1),A2)`

Result: chair, desk, lamp; monitor; dock, cable; desk, lamp; mouse

## How it works

RIGHT with no length returns the last character. If it is a comma, LEFT keeps everything except it; if not, the text comes back unchanged. That is the difference from simply cutting the last character off every row.

## Other ways

- `=IF(RIGHT(TRIM(A2))=",",LEFT(TRIM(A2),LEN(TRIM(A2))-1),TRIM(A2))`: Trims first, so a comma followed by a space ("dock, cable, ") is caught too.
- `=REGEXREPLACE(A2,",\s*$","")`: Google Sheets: delete a comma and any spaces at the very end.

## Common mistakes

- A space after the comma hides it from RIGHT. Use the TRIM version for exported data.
- Two trailing commas lose only one. In Google Sheets, `",+\s*$"` removes them all.

## Questions

**How do I remove a trailing slash from URLs?**

Swap the character: `=IF(RIGHT(A2)="/",LEFT(A2,LEN(A2)-1),A2)`.

**How do I remove a leading comma?**

Check the first character: `=IF(LEFT(A2)=",",MID(A2,2,LEN(A2)),A2)`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/remove-a-trailing-comma
