Removing the Last Digit in a Number

Written by Allen Wyatt (last updated October 31, 2020)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


1

Sherry has a column of numbers ranging from 13 to 15 digits long. She needs to remove just the last digit in each number and wonders how this can be easily done.

The easiest way is to use a formula to strip off the digit. The following works just fine, assuming that the original value is in cell A1:

=LEFT(A1,LEN(A1)-1)*1

What is returned by the LEFT function is a string, which is why it is multiplied by 1 at the end of the formula—it converts that string value back into a numeric value.

Perhaps the shortest formula would be the following, however:

=TRUNC(A1/10)

Dividing by 10, of course, is a quick way to move the decimal point one position to the left. You could use the INT function instead of TRUNC, but you should only do so if the original values are all positive numbers. (INT and TRUNC behave differently from each other when working with negative values.)

Obviously, the formulas described above require the use of a helper column. They also aren't terribly discriminating; they will remove the last digit from any value in cell A1 and they won't "adjust" if A1 contains text or is empty. If you want a bit more flexibility, you might consider using a macro:

Sub ShortenByOne()
    Dim c As Range

    For Each c In Selection
        If (Not c.HasFormula) And (Application.WorksheetFunction.IsNumber(c)) Then
            c = Left(c, Len(c) - 1)
        End If
    Next c
End Sub

To use the macro, select the range of cells you want to affect and then run it. The values are changed to reflect the dropping of the right-most digit. Note that the macro won't make any changes in cells containing formulas or cells that don't contain numeric values. (The IsNumber worksheet function is used in preference to the IsNumeric function because IsNumeric will treat empty cells as if they are actually numeric which will crash the macro without additional testing. IsNumber doesn't exhibit that problem.)

If you want to make sure that only cells containing 13, 14, or 15 digits are modified, then you can use a variation on the above macro:

Sub ShortenByOne()
    Dim c As Range

    For Each c In Selection
        If (Not c.HasFormula) And (Application.WorksheetFunction.IsNumber(c)) Then
            If Len(c) > 12 And Len(c) < 16 Then
                c = Left(c, Len(c) - 1)
            End If
        End If
    Next c
End Sub

Note that after the macro determines that the cell doesn't contain a formula and that it contains a number, then it checks to see if the length of the number is greater than 12 and less than 16. (In other words, 13, 14, or 15.) Only then does it strip off the right-most digit.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13796) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Using AutoFiltering

Excel's AutoFilter tool is a great way to make a long list of items much more manageable. This tip explains how to set up ...

Discover More

Entering a Degree Sign

One of the more common symbols that people need to use in their writing is the degree symbol, typically used after a ...

Discover More

Only Inline Figures Can be Seen and Printed

Insert a graphic into a document and you expect to be able to see it. What do you do if it isn't displayed, however? Here ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Formula Shows Instead of Formula Result

When you enter a formula in a cell, you expect Excel to display the result of that formula once you are completed. If ...

Discover More

Strange Value Results in a Cell

When Excel performs a calculation, the results you see in an unformatted cell may cause a bit of concern. This tip ...

Discover More

Checking for Either of Two Text Values

Using a formula to find information in a text value is easy. Using a formula to find either of two text values within a ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 2 + 2?

2020-11-02 12:40:25

Yvan Loranger

I prefer =LEFT(A1,LEN(A1)-1)*1 over =TRUNC(A1/10)
since the first properly handles decimals as well as whole numbers in the 13-15digit samples.
Example: 111111111111.1 is properly handled by the LEFT function.
thanks


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.