Sometimes you may find unpleasant surprises in data when you import a file into the Microsoft Excel spreadsheet application. In some cases, you might have an extraneous character, such as a comma, that appears at the end of cell strings. To remove trailing commas from your Excel cells, you can create a function that checks for a comma at the end of a string and then deletes the final character in the string if it is a comma. Once you've used the formula to strip commas from the cell strings, you can use the Paste Special function to copy the formula output values back to the original data.
Open the worksheet that contains the data from which you want to remove trailing commas.
Video of the Day
Right-click the header of the column directly to the right of the data column that you want to clean. Click "Insert" in the menu to insert a new function column.
Type the following in the cell in the formula column adjacent to the first data cell:
Substitute the cell address of your first data cell in place of all instances of "A1" in the above example.
Press "Enter." Excel first determines whether the rightmost value in the data cell is a comma. If so, it determines the number of characters in the cell using the "Len" function and then returns only the leftmost N minus 1 characters, thus omitting the comma. If no comma is detected at the end of the string, then Excel returns the original cell value.
Right-click the formula cell and click "Copy." Paste the formula into the cell directly to the right of all cells from which you want to clean the commas. Excel will perform the comma-trimming function on all cells and return the update value in the formula column.
Highlight all formula cells, then right-click the array and choose "Copy."
Highlight the original data cells, then right-click the array and choose "Paste Special." Click the radio button next to "Values," then click the "OK" button. Excel will copy the output strings from the comma-less formula cells into your original data cells as static character strings.
Highlight the formula column, then right-click the array and click "Delete" from the menu. This will delete the formula column now that a permanent copy of the formula output has been saved in the original data column.