+ Reply to Thread
Results 1 to 26 of 26

Convert dimensions: mm to inches

Hybrid View

  1. #1
    Registered User
    Join Date
    08-02-2012
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    30

    Convert dimensions: mm to inches

    I have a large column of numbers written like this: (90 * 120 * 85) I need to convert these mm numbers to inches in the next column over. Any help is appreciated!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Convert dimensions: mm to inches

    Hi,

    =A1/25.4
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    08-02-2012
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    30

    Re: Convert dimensions: mm to inches

    It gives me an #VALUE when I put that formula in. It also tries to mulitply * the numbers since thats how they were written before ... 90*120*85. These are dimensions... I would need this to be translated to 3.54*4.72*3.35. Thanks!

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Convert dimensions: mm to inches

    Does your original data include the paranthesis?

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Convert dimensions: mm to inches

    Hi,

    You said you wanted to convert them to inches. I implied that you wanted the result in inches. Are there always three numbers or can they vary from row to row?. e.g. 10*20*30*40*50...etc

  6. #6
    Registered User
    Join Date
    08-02-2012
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    30

    Re: Convert dimensions: mm to inches

    Yes, I didnt explain thoroughly enough before. Yes, there are always 3 numbers e.g. 90*120*85. HxWxD Thanks.

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Convert dimensions: mm to inches

    Looks ugly, but best I can come up with

    =ROUND(LEFT(A2,FIND(" ",A2)-1)/25.4,2)&" * "&ROUND(TRIM(MID(SUBSTITUTE(A2,"*",REPT(" ",10)),10,10))/25.4,2)&" * "&ROUND(SUBSTITUTE(TRIM(MID(SUBSTITUTE(A2,"*",REPT(" ",10)),20,20)),")","")/25.4,2)

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Convert dimensions: mm to inches

    Another completely different approach would be to split column A into three columns using the '*' as the delimiter symbol, then join them all together again with

    TEXT(A1/2.54,"0.00")&" * "&TEXT(B1/2.54,"0.00")&" * "&TEXT(C1/2.54,"0.00")

  9. #9
    Registered User
    Join Date
    08-02-2012
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    30

    Re: Convert dimensions: mm to inches

    No, no parenthesis.

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,720

    Re: Convert dimensions: mm to inches

    Perhaps it would be simpler to split the 3 values into 3 cells using "text to columns" functionality (with * as delimiter), then you can use a simple formula to divide each value by 25.4 and re-concatenate them.

    You can use a single formula but it's a little long, i.e.

    =FIXED(LEFT(A1,FIND("*",A1)-1)/25.4)&"*"&FIXED(MID(A1,FIND("*",A1)+1,FIND("*",A1,FIND("*",A1)+1)-FIND("*",A1)-1)/25.4)&"*"&FIXED(REPLACE(A1,1,FIND("*",A1,FIND("*",A1)+1),"")/25.4)
    Audere est facere

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,720

    Re: Convert dimensions: mm to inches

    OK, I'm going to steal some of the best bits of jason's suggestion to shorten mine, i.e.

    =FIXED(LEFT(A1,FIND("*",A1)-1)/25.4)&"*"&FIXED(MID(SUBSTITUTE(A1,"*",REPT(" ",9)),9,9)/25.4)&"*"&FIXED(REPLACE(A1,1,FIND("*",A1,FIND("*",A1)+1),"")/25.4)

    any advance?

  12. #12
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Convert dimensions: mm to inches

    Quote Originally Posted by daddylonglegs View Post
    any advance?
    Not without resorting to a UDF.

  13. #13
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,720

    Re: Convert dimensions: mm to inches

    Quote Originally Posted by daddylonglegs View Post
    any advance?
    That was simply an invitation for others to improve my suggestion (half jokingly). Jason suggests you might only be able to do that with a "UDF"

    UDF = "User defined function", a function defined in VBA

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Convert dimensions: mm to inches

    For some variety....

    =FIXED(LEFT(A1,FIND("*",A1)-1)/25.4)&" * "&FIXED(TRIM(MID(SUBSTITUTE(A1,"*",REPT(" ",100)),101,100))/25.4)&" * "&FIXED(TRIM(MID(SUBSTITUTE(A1,"*",REPT(" ",100)),201,100))/25.4)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  15. #15
    Registered User
    Join Date
    08-02-2012
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    30

    Re: Convert dimensions: mm to inches

    Both formulas work perfectly. The only difference, Jasons has spaces between the numbers and *'s. Thank you daddylonglegs and jason!!

  16. #16
    Registered User
    Join Date
    08-02-2012
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    30

    Re: Convert dimensions: mm to inches

    Just curious... What do you mean by advance and UDF?

  17. #17
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Convert dimensions: mm to inches

    Advance was meaning improvements / changes to make the formula shorter or more efficient. As in post #10 you can sometimes look at different suggestions posted by other people, making a better formula by mixing the methods used.

    A UDF is a custom function made in VBA, which you need to copy into the code editor (in excel press Alt F11, then in the editor menu choose Insert, then Module).

    Option Explicit
    Public Function mmtoinches(ByVal str As String)
    Dim tmp, a As Long, tmpstr As String
    tmp = Split(str, "*")
    For a = 0 To UBound(tmp)
        tmpstr = tmpstr & Round(CDbl(tmp(a)) / 25.4, 2) & " * "
    Next
    mmtoinches = Left(tmpstr, Len(tmpstr) - 3)
    End Function
    Then instead of those long formula in the earlier replies, you simply use =mmtoinches(A2)

  18. #18
    Registered User
    Join Date
    08-02-2012
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    30

    Re: Convert dimensions: mm to inches

    Ah, ok. Thanks for the explanation.

  19. #19
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Convert dimensions: mm to inches

    and mine wasn't really an improvement, just an alternative... I was typing and posting at same time dll posted his challenge... so didn't see it by the time I posted

    P.s.... although shorter isn't always most efficient either

  20. #20
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,720

    Re: Convert dimensions: mm to inches

    Quote Originally Posted by NBVC View Post
    P.s.... although shorter isn't always most efficient either
    Damn! All these years.......

  21. #21
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Convert dimensions: mm to inches

    obviously, it wasn't directed at you dll. Just a general comment.

  22. #22
    Registered User
    Join Date
    08-02-2012
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    30

    Re: Convert dimensions: mm to inches

    I do have another problem. Not sure if I should create a new thread but here goes... Same worksheet: I converted everything to inches. Now I see one mfg has thier dimensions listed as HxWxD and the other mfg has WxHxD. Is there a way to make it so they will be in the correct order when converting to inches? Ex. Started with 90*120*70 (W*H*D) which you gave me the formula to convert to 3.54*4.72*2.76. Now, I'd like to switch the first two numbers and convert to 120*90*70 (H*W*D)and then into inches which is 4.72*3.54*2.76.

  23. #23
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Convert dimensions: mm to inches

    Hi,

    How will a formula know that the first entry is the Height?

    (late edit... unless you can apply a rule like the height is always less than the width)

    Unless you have an indicator somewhere and can recognise which is which, the best you can do is manually change the formula/macro for the relevant manufacturer

    In the case of the text to columns approach I suggested just swap the references around. e.g.

    =TEXT(B1/2.54,"0.00")&" * "&TEXT(A1/2.54,"0.00")&" * "&TEXT(C1/2.54,"0.00")
    Last edited by Richard Buttrey; 08-13-2012 at 11:31 AM.

  24. #24
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Convert dimensions: mm to inches

    Maybe you should also mark the thread as Unsolved given the addendum

  25. #25
    Registered User
    Join Date
    08-02-2012
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    30

    Re: Convert dimensions: mm to inches

    Thanks again to all of you who have responded. I have everything I need for this spreadsheet and future projects like this one. Your quick response is very much appreciated!

  26. #26
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Convert dimensions: mm to inches

    From your last response it looks like you have a solution that you're happy with but I'll post this anyway in case it's of use.

    Option Explicit
    Public Function mmtoinches(ByVal str As String, Optional order As String = "whd")
    Dim tmp, a As Long, tmpstr As String, tval As Double, w As Boolean, h As Boolean, d As Boolean, funcerr
    tmp = Split(str, "*")
    For a = 0 To 2
        Select Case LCase(Mid(order, a + 1, 1))
            Case Is = "w"
                If w Then GoTo funcerr
                tval = Round(CDbl(tmp(0)) / 25.4, 2)
                w = True
            Case Is = "h"
                If h Then GoTo funcerr
                tval = Round(CDbl(tmp(1)) / 25.4, 2)
                h = True
            Case Is = "d"
                If d Then GoTo funcerr
                tval = Round(CDbl(tmp(2)) / 25.4, 2)
                d = True
            Case Else
                GoTo funcerr
        End Select
            tmpstr = tmpstr & tval & " * "
    Next
        mmtoinches = Left(tmpstr, Len(tmpstr) - 3)
        Exit Function
    funcerr:
        mmtoinches = CVErr(xlErrNA)
    End Function
    The function is set up for a default format of w*h*d, the input value must be in this order, the output order can be defined by the optional second parameter of the function.

    =mmtoinches(A2) will return the result in the default format.
    =mmtoinches(A2,"hwd") will return the result in the format h*w*d, this is for example, it can be defined in any order, dwh, hdw, etc.

    Failsafes included so duplicate dimensions i.e. "hhd" or unknown characters will return a #N/A! error.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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