Log in  \/ 
x
or
x
x
Register  \/ 
x

or

Excel remove last or trailing comma in a cell

Sometimes when importing data from other files into Excel spreadsheet application, you may find there are extraneous characters such as commas appearing at the end of the strings. This tutorial explains how to use a combination of the IF, RIGHT, LEFT and LEN functions to remove the trailing comma in a cell in Excel.


How to remove the last or trailing comma in a cell in Excel?

As the below screenshot shown, cells in column B contain the data from which you want to remove trailing commas. Please do as follows to achieve it.

Generic formula

=IF(RIGHT(A1,1)=",",LEFT(A1,LEN(A1)-1),A1)

Arguments

A1: Represents the cell contains the text string from which you want to remove trailing comma.

How to use this formula?

1. Select a blank cell to output the text after removing the trailing comma. In this case, I select D3.

2. Enter the below formula into it and press the Enter key. Select the result cell, and then drag its Fill Handle all the way down to apply the formula to other cells.

=IF(RIGHT(B3,1)=",",LEFT(B3,LEN(B3)-1),B3)

Then you can see all commas at the end of the strings are removed immediately.

Note: In this formula, B3 is the cell containing the text string from which you want to remove trailing comma. Please change it as you need.

How this formula works?

=IF(RIGHT(B3,1)=",",LEFT(B3,LEN(B3)-1),B3)

1. LEFT(B3,LEN(B3)-1)

  • The LEN function calculates the total length of text string "Excel, handy, addin," and returns the result as 20;
  • And then the LEFT function extract 19 (20-1=19) characters from the left side of the text string "Excel, handy, addin," and gets the result "Excel, handy, addin".

2. IF(RIGHT("Excel, handy, addin,",1)=",","Excel, handy, addin","Excel, handy, addin,")

  • Here determines whether the rightmost value in text string "Excel, handy, addin," is a comma. If a comma is detected at the end of the string, it returns "Excel, handy, addin", otherwise, returns the original text string "Excel, handy, addin,".

Related functions

Excel IF function
The Excel IF function performs a simple logical test which depending on the comparison result, and it returns one value if a result is TRUE, or another value if result is FALSE.

Excel RIGHT function
The Excel RIGHT function extracts a specific number of characters from the right side of the text string.

Excel LEFT function
The Excel LEFT function extracts the given number of characters from the left side of a supplied string.

Excel LEN function
The Excel LEN function returns the number of characters in a text string.


Related formulas

Remove The First Or Last Word From A String
This tutorial explains how to remove only the first or last word from the text string in a cell with formulas in Excel.

Remove First N Characters From Cell
This tutorial introduces two formulas to help you easily remove the first n characters from a cell in Excel.

Remove Line Breaks From Cells In Excel
This tutorial provides three formulas to help you removing line breaks (which are occurred by pressing Alt + Enter keys in a cell) from specific cells in Excel.

Remove Text From Cell By Matching The Content
This article shows you how to use the SUBSTITUTE function to remove part of text string from specified cells by matching content.

Remove Text From A Cell Based On Specific Position
This tutorial explains how to use formulas to remove text from a cell based on specific position in Excel.


The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.