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

1. ## 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,

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

Please provide more detailed information.

3. ## 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. ## 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. ## 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
•