Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

An Excel conversion question 3

Status
Not open for further replies.

jerry1423

Mechanical
Aug 19, 2005
3,428
Does anybody know if it is possible to covert meters to feet-fractional inches in excel?
I could not find anything on this.

Thanks
 
Replies continue below

Recommended for you

Sure, you just have to write a function.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Jerry…

Over the past few months, I have posted a bunch of things to the PTC Mathcad boards, including a feet-inches-fractions calculator. Included in that particular post is an Excel spreadsheet to do F-I-F calculations. My spreadsheet does NOT include metric to F-I-F, but I think you should be able to use my spreadsheet as a way to shorten your task. You can find it here:
Fred

==========
"Is it the only lesson of history that mankind is unteachable?"
--Winston S. Churchill
 
The closest I can get using built in functions, without getting excessively complicated, is to use the Convert function, split the result into two cells, and format the inches cells as fractions. For a value in A1:
Feet, in B1: =INT(CONVERT($A1,"m","ft"))
Inches, in C1, format as fraction: =((CONVERT($A1,"m","ft")-B1)*12)

The problems with this are that you probably won't like the numbers they choose for the fraction, and the value is now split over two cells, so you can't use it as a value in further calculations.

A UDF should be pretty easy, I'll have a look.

Also for a general purpose unit converter, have a look at:


Doug Jenkins
Interactive Design Services
 
Code for a UDF to convert metres to feet and fractional inches is listed below.
=m2ftin(10) returns 34' 5.39"
=m2ftin(10, 16) returns 34' 5 6/16"

Code:
Function M2Ftin(Mval As Double, Optional Denom As Long = 0, Optional InDP As Long = 2) As String
Dim ft As Double, inch1 As Double, inch2 As Double, Frac As Long, m2in As Double, Rtn As String
'Converts MVal to ft and inches, returning a string
'If Denom is > 0 then inches are returned as a fraction with the specified denominator
' If Denom is zero or blank inches are returned as a decimal with InDP decimal places, default 2
    m2in = 1000 / 25.4
    inch1 = Mval * m2in
    ft = Int(inch1 / 12)
    inch2 = inch1 - ft * 12
    ft = Int(inch1 / 12)
    If Denom > 0 Then
        Frac = Round((inch2 - Int(inch2)) * Denom, 0)
        inch2 = Int(inch2)
    Else
        inch2 = Round(inch2, InDP)
    End If
    Rtn = ft & "' " & inch2
    If Denom > 0 Then
        If Frac > 0 Then
            Rtn = Rtn & " " & Frac & "/" & Denom & """"
        Else
            Rtn = Rtn & """"
        End If
    Else
        Rtn = Rtn & """"
    End If
    M2Ftin = Rtn
End Function


Doug Jenkins
Interactive Design Services
 
Here's another on-sheet method, from:

If you have the dimension in feet in A2 then:
=INT(A2)&"' "&TEXT(12*(A2-INT(A2)),"# #/#")&CHAR(34)
will give feet and inches with fractions.

If you want to convert from m to feet and inches all in the one cell it would be (with metres in A1) :
=INT(CONVERT(A1,"m","ft"))&"' "&TEXT(12*(CONVERT(A1,"m","ft")-INT(CONVERT(A1,"m","ft"))),"# #/#")&CHAR(34)

If you have decimal inches as a value in a cell you can format it to display as eighths, sixteenths, etc, but I don't know how to do that in a text formula.

Doug Jenkins
Interactive Design Services
 
just got back to this thread after being gone for several days
Thank you very much for all the replies, incredibly helpful
 
Displaying the text formula with a specified denominator turns out to be pretty easy:
=INT(A2)&"' "&TEXT(12*(A2-INT(A2)),"# #/16")&CHAR(34)
see:

for more details, and download of UDFs providing conversion in both directions, and unit conversion spreadsheet.

Doug Jenkins
Interactive Design Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor