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: Developing Reciprocal Conversion Formulas.

Developing Reciprocal Conversion Formulas

Written by Allen Wyatt (last updated April 9, 2022)
This tip applies to Excel 97, 2000, 2002, and 2003


Jeremy posed a problem that is based on two cells, A1 and C1. These cells are designed to contain inches and millimeters, respectively. Jeremy wants a way that someone could enter a value in A1 and it would be converted to millimeters in C1. Conversely, they could enter a value in C1 and it would be converted to inches in A1.

Doing the conversion, of course, isn't the real issue. The problem is that if someone enters a value in A1, that value will overwrite any formula that may be in that cell, and mean that any subsequent value entered in cell C1 would not give the required conversion in the previously overwritten A1.

There are a couple of different ways that this could be approached. If you don't mind expanding your worksheet design to include two more cells, those cells could be used strictly for input and cells A1 and C1 could be used strictly for output. One of the input cells could contain the value to be converted and the other could contain the measurement unit of the input value (in or mm, for instance).

Of course, if you want to really limit yourself to two cells, then you will need to resort to using macros to do the actual conversion. You can use a worksheet event that is triggered every time a cell value is changed, and the event handler could check to see if the cell being changes is either A1 or C1. The following macro gives an example of how this could work:

Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    With ActiveSheet
        If Target = .[A1] Then
            .[C1].Value = .[A1].Value * 25.4
        ElseIf Target = .[C1] Then
            .[A1].Value = .[C1].Value / 25.4
        End If
    End With
    Application.EnableEvents = True
End Sub

Note that you don't have to have any formulas in cells A1 or C1; the formulas are in the macro itself. If there is a change in cell A1 (inches are entered by the user), then the value in cell C1 is changed by the macro. Likewise, if there is a change in cell C1 (millimeters are entered by the user), then the value in cell A1 is changed by the macro. A change in any other cell besides A1 or C1 is ignored by the macro.

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 (3277) 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: Developing Reciprocal Conversion Formulas.

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

Adding Tabs at the Beginning of a Line

Press a tab at the beginning of a paragraph, and Word normally assumes you want to indent the paragraph. If you don't ...

Discover More

Maintaining Accuracy of Significant Digits

If you work in the sciences or mathematics, you know that significant digits are important. This tip answers questions ...

Discover More

Changing Roman Numerals to Arabic

In some documents Roman numerals might be used quite a bit. If you ever want to change the Roman numerals to their Arabic ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling 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

Converting Phone Numbers

Sometimes you receive a phone number that contains alphabetic characters and you need to convert it to a purely numeric ...

Discover More

Getting Rid of 8-Bit ASCII Characters

When working with data created outside of Excel, you may need to check that data to make sure it contains no unwanted ...

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 1 + 1?

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.