Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Removing Dashes from ISBN Numbers.

Removing Dashes from ISBN Numbers

Written by Allen Wyatt (last updated September 23, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


1

Ciaran works in a library, and often has to work with long lists of ISBN numbers in Excel. The numbers must contain either 10 or 13 digits, may contain dashes, and may have leading zeros. He uses text format for cells containing ISBNs in order to keep them intact as text strings. For some purposes, the dashes in the ISBNs have to be stripped out (he uses Find and Replace for this) and that's where the trouble starts. 0-241-95011-2 becomes 241950112 (now it's dropped to 9 digits), and worse, 978-0-00-200784-9 becomes 9.78E+12 (scientific notation). Ciaran can't find any way of working around these two issues, no matter what he does with formatting before or after using Find and Replace to get rid of the dashes.

What is happening is that when you edit the cells, Excel is parsing the cell contents as numbers instead of as text. In this case, the best solution is to make sure that your cell contents are preceded with an apostrophe before you do the Find and Replace to get rid of the dashes. If you have a worksheet that contains a lot of ISBN numbers in column A, you can add the apostrophes with a formula such as the following:

= "'" & A1

You can then copy the results of the formulas and then use Paste Special to paste values back into column A. Each value in column A will then include the apostrophe. When you later perform the Find and Replace, the leading zeroes will still be present, and you won't get any attempts at scientific notation.

The reason this works is because the apostrophe is an indicator to Excel that the cell contents should be treated as text. The apostrophe isn't displayed in the worksheet, but it is part of the cell contents, as you can tell by looking at the Formula bar.

Another approach is to bypass using Find and Replace to get rid of the dashes. Instead use the SUBSTITUTE function to remove them, in this manner:

=SUBSTITUTE(A1,"-","")

The SUBSTITUTE worksheet function returns a text value, so any leading zeroes are maintained, and Excel doesn't try to convert the numbers to use a numeric format.

If you routinely need to remove the dashes from a range of cells containing ISBNs, you might be better served to use a macro to do the operation. The following macro works upon whatever cells you've selected before running it.

Sub RemoveDashes()
    Dim c As Range
    Dim sISBN As String

    Application.ScreenUpdating = False
    For Each c In Selection
        sISBN = Replace(c, "-", "")
        c.NumberFormat = "@"
        c.Value = "'" & sISBN
    Next
    Application.ScreenUpdating = True
End Sub

Basically, the macro does three things: It removes the dashes, it formats the cell as text, and it places the stripped ISBN back in the cell with an apostrophe before it.

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 (9928) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Removing Dashes from ISBN Numbers.

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

Understanding Leading

Those with a publishing, typographic, or design background may understand what leading is, but not how to adjust the ...

Discover More

Using Less Paper on Printouts

If a worksheet contains nothing but a bunch of values in column A, you may be loathe to print the worksheet and "waste" a ...

Discover More

Excel 2016 PivotTables for the Faint of Heart (Table of Contents)

PivotTables are a powerful tool for consolidating huge amounts of data. PivotTables 2016 for the Faint of Heart ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Extracting First and Last Words

When working with text phrases stored in cells, it might be helpful to be able to extract words from the phrase. In this ...

Discover More

Deleting Duplicate Text Values

Got a list of data from which you want to delete duplicates? There are a couple of techniques you can use to get rid of ...

Discover More

Alphabetic Column Designation

Want to know the letters assigned by Excel to a particular column? Excel normally deals with column numbers, but you can ...

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 seven minus 7?

2024-09-23 18:04:26

Chester Hood

Please note that the last "digit" (the check digit) in an ISBN may be the letter "X".

From: https://www.isbn.org/faqs_general_questions#isbn_faq5

Why do some ISBNs end in an "X"?
In the case of the check digit, the last digit of the ISBN, the upper case X can appear. The method of determining the check digit for the ISBN is the modulus 11 with the weighting factors 10 to 1. The Roman numeral X is used in lieu of 10 where ten would occur as a check digit.


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.