Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Working with Imperial Linear Distances.

Working with Imperial Linear Distances

Written by Allen Wyatt (last updated August 7, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


Peter asked if it was possible in Excel to create a custom number format that will deal with imperial linear distances, such as inches, feet, miles, etc. The short answer is that no, this is not possible. Excel works natively in the decimal system, and many imperial measuring systems are based on other numeric systems (feet on base 12, for instance). While custom formatting can change the way that numbers are displayed, it cannot perform the conversions necessary for imperial measurements.

Your best bet is to keep the different units of whatever imperial measurement you want in different cells. For instance, a distance of 3 miles, 428 feet, and 7 inches could be kept in three cells, one for miles, one for feet, and the other for inches. You could then write the formulas necessary to convert to whatever measurement system you desire. There are also Excel add-ins available around the Internet (a quick search will find them) that can allow you to use this technique to work with linear measurements.

Another approach is to develop a custom function or macro that would convert a value into a linear measurement and display it as text. You couldn't use the result in math functions, but it may give you want you want for your workbook. Consider, for example, the following simple macro:

Function N2MYFI(x) As String
    Dim x1 as Long
    Dim FinalAnswer As String

    x1 = x
    Distances = Array(63360, 36, 12, 1)
    
    FinalAnswer = ""
    For Each Item In Distances
        FinalAnswer = FinalAnswer & " " & Int(x1 / Item)
        x1 = x1 - Item * Int(x1 / Item)
    Next

    N2MYFI = Trim(FinalAnswer)
End Function

This function returns four numbers, in a string, that represent the number of miles, yards, feet, and inches (MYFI) in a raw value. It is assumed that the value fed to the function is in inches, such as the following:

=N2MYFI(100)

This returns the string "0 2 2 4", which means there are 0 miles, 2 yards, 2 feet, and 4 inches in 100 inches. The function could easily be changed to return the values in any format desired.

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 (3137) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Working with Imperial Linear Distances.

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

Moving Files or Folders

A common operation within Windows is to move files and folders from one location to another. Here are the two major ways ...

Discover More

Getting Rid of "Comment" in Comments

When you add a comment to a document, Word presents that comment in a very specific way. If you want to change the way in ...

Discover More

Getting Rid of Many Hyperlinks

Need to get rid of hyperlinks that result when you paste information from the Internet into your document? Here's some ...

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 (menu)

Automatically Converting to GMT

You know what time it is, right? (Quick—look at your watch.) What if you want to know what time it is in Greenwich, ...

Discover More

Breaking Up Variable-Length Part Numbers

Part numbers can often be long, made up of other component elements. Breaking up part numbers into individual components ...

Discover More

Pulling Apart Characters in a Long String

You can easily use formulas to pull apart text stored in a cell. For instance, if you need to pull individual characters ...

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 2?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.