Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Nov 2007
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Conversion of output values to SI (Excel 03 Vb)

    Hi all,
    I have a Vb codes that will provide output to excel cells, I would think that it will be nice if it can do a conversion on the output to SI or Imperial respectively.
    How could i do that?

    I was thinking if i could create a command button on the worksheet that work with a macro to do the conversion. However i am confuse about the code part,
    Please advise

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Conversion of output values to SI (Excel 03 Vb)

    Please provide more detailed information.

  3. #3
    Lounger
    Join Date
    Nov 2007
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conversion of output values to SI (Excel 03 Vb)

    Ok,
    lets say my out put on cell(0,0) is 24 inch
    but i would like to change it to SI Unit which will be a multiplication of 0.254 which is to metres
    i would like to replace the value in the cell with the new value , which will be 6.35 metres
    therefore when i click the command button the value will be changed in to 6.35 meter replacing the 25inch
    I am wondering how i can do that ?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Conversion of output values to SI (Excel 03 Vb)

    You could use a cell (which can be hidden) to keep track of the currently used system, let's say cell K1.
    It contains TRUE if the values are displayed in the metric system and FALSE if they are displayed in the Imperial system.

    The macro to be run by the command button could look like this:

    Sub ConvertValues()
    ' Toggle K1
    Range("K1") = Not Range("K1")
    If Range("K1") = True Then
    ' Convert to metric
    ' Inches to metres
    Range("A1") = Range("A1") * 0.0254
    ' Pounds to kilograms
    Range("B1") = Range("B1") * 0.453
    ' Etc.
    Else
    ' Convert to Imperial
    ' Metres to inches
    Range("A1") = Range("A1") / 0.0254
    ' Kilograms to pounds
    Range("B1") = Range("B1") / 0.453
    ' Etc.
    End If
    End Sub

    I hope that 24 inches comes out as 0.61 m and not as 6.35 m!

  5. #5
    Lounger
    Join Date
    Nov 2007
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conversion of output values to SI (Excel 03 Vb)

    Hey Hans,
    Thanks ... I ll make sure i convert it right
    haha... the code work just fine.. i like it

Posting Permissions

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