+ Reply to Thread
Results 1 to 11 of 11

Unit conversion

  1. #1
    Registered User
    Join Date
    11-14-2007
    Posts
    11

    Unit conversion

    Let's say I have two cells, A1 and C1, that are designed to contain
    inches and millimeters, respectively. I want 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. The conversion isn't the issue; I know how to do
    that. But if someone enters a value in A1, that value will overwrite
    any formula I may have in that cell, and mean that any subsequent
    value entered in cell C1 would not give the required conversion in
    the previously overwritten A1. Is there a way I can have these two
    related cells always give the desired conversions, without losing the
    formulas and without the formulas being considered circular?

    thanks!

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    This can be accomplished with VBA.

    Right-click on the worksheet tab, select View Code, and copy the following code:
    Please Login or Register  to view this content.
    HTH

    Jason

  3. #3
    Registered User
    Join Date
    11-14-2007
    Posts
    11
    fantastic!

    works perfectly.


    Thanks a lot

    ~hollanu~

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    No problem. Glad I could help.

    Jason

  5. #5
    Registered User
    Join Date
    11-14-2007
    Posts
    11
    need more help.

    the code above works great, but I have multiple cells requiring the same treatment that are not necessarily one after another. i.e. A1, A6, B9, C2, etc. I'm new to VBA, so I just tried copying the above code for each of the new cell pairs, but received the following error message "Ambiguous Name Detected".

    thanks again in advance

  6. #6
    Registered User
    Join Date
    11-14-2007
    Posts
    11
    nevermind, I think I have figured it out.

    Thanks anyway

  7. #7
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    If you need more help on it, be sure to post up a full copy of the revised procedure, or, if able, a copy of the workbook, so that someone can help you out.

    Jason

  8. #8
    Registered User
    Join Date
    12-13-2007
    Posts
    17
    Is there a way to do this in the same cell?

    Right now I have data entry in A2, and a drop down in A1 that says Metric or Imperial. I want the data in A2 to change depending on what is selected in A1 for the units. Is this possible, do either of you know?

  9. #9
    Registered User
    Join Date
    10-05-2012
    Location
    USA
    MS-Off Ver
    excel 2010
    Posts
    8

    Re: Unit conversion

    Is there a way that I could use the below code to calculate a multiple imput formula that would calculate in multiple directions. For example if I have the equation--vehicle speed=rpm x gear ratio x tire size--I would like to be able to imput any combination of three variables and have the fourth one calculated.

    Quote Originally Posted by jasoncw View Post
    This can be accomplished with VBA.

    Right-click on the worksheet tab, select View Code, and copy the following code:
    Please Login or Register  to view this content.
    HTH

    Jason

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Unit conversion

    walterst,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  11. #11
    Registered User
    Join Date
    10-05-2012
    Location
    USA
    MS-Off Ver
    excel 2010
    Posts
    8

    Re: Unit conversion

    thank you I saw this as being the same question with a minor adjustment and thought this would be an appropriate approach. i will comply with your direction

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1